Skip to content

Star importing TypeVar conflicts with 3.13 type var syntax #10900

@lukas-lang

Description

@lukas-lang

Describe the bug
Star importing a TypeVar definition with the same name as a type var declared using the 3.13 syntax leads to strange behavior, seemingly caused by inconsistent name lookup. The errors look like

Cannot assign to attribute "val" for class "Foo[T@Foo]*". Type "T@Foo" is not assignable to type "T@Foo"

Code or Screenshots

Create two files:

  • foo.py:
    from typing import TypeVar
    
    T = TypeVar("T")
  • bar.py:
    from .foo import *
    
    class Foo[T]:
        def __init__(self, val: T):
            self.val: T = val
Image

VS Code extension or command-line
This is using the VSCode extension version 1.1.405

Metadata

Metadata

Assignees

No one assigned

    Labels

    addressed in next versionIssue is fixed and will appear in next published versionbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions