Skip to content

Generic class atributes aren't fully instantiated #2878

Closed
@miedzinski

Description

@miedzinski
T = TypeVar('T')
class A(Generic[T]):
    def f(self, x: T) -> None: ...
class B(Generic[T]):
    x = None  # type: A[T]

B[int].x.f(0)  # E: Argument 1 to "f" of "A" has incompatible type "int"; expected "T"

Discovered while reviewing #2873.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions