Skip to content

We lose information on assigning a type object to a variable #3067

@sixolet

Description

@sixolet
class A: pass

B: Type[A]
reveal_type(B)  # E: Revealed type is 'Type[__main__.A]'
B = A
reveal_type(B) # E: Revealed type is 'builtins.None'
b = B() # E: None not callable

Commentary from @pkch :

it seems the problem is that reveal_type calls meet_simple() on Type[A] and A, which are represented as TypeType and Callable. And meet_simple logic doesn't notice that they are compatible, so it returns None. I'm not sure what the difference is between meet_simple and meet_type, but the two would behave identically in this situation.

Attn @ilevkivskyi, who is hanging out in this area of code I think.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions