Skip to content

Generic inner classes sees type variable from outer class #3144

Open
@pkch

Description

@pkch
T = TypeVar('T')
class Outer(Generic[T]):
    class Inner:
        x: T  # E: Invalid type "test.T" (correct)
        def f(self, x: T) -> T: ... # ok (incorrect)
        def g(self) -> None:
            y: T  # E: Invalid type "test.T" (correct)

Source

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions