Skip to content

Qualified alias names are mishandled #3145

Closed
@pkch

Description

@pkch
T = TypeVar('T')

class X(Generic[T]):
    A = X[T]
    def f(self, x: int = 1) -> X[T]: ...
    a: X[T]
    b: A = a # ok
    def g(self) -> None:
        a: X[T]
        b: X.A = a # ok


def g(x: X[T]) -> None:
    p: X[T] = x.f() # ok
    q: X.A = x.f() # fail

I think it should pass, unless qualified aliases are not allowed (in which case it should fail in X.g()). In addition, the error is confusing: Incompatible types in assignment (expression has type m.X[T], variable has type m.X[T]).

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions