Closed
Description
class A: pass
x: Tuple[A]
x = A, # E: Incompatible types in assignment (expression has type "Tuple[A]", variable has type "Tuple[A]")
y: Tuple[Type[A]]
y = A, # OK, expected
def f(x: Tuple[A]) -> None: return None
f((A,)) # E: Argument 1 to "f" has incompatible type "Tuple[A]"; expected "Tuple[A]"
reveal_type((A,)) # E: Revealed type is 'Tuple[def () -> x.A]'
z: A
z = A # E: Incompatible types in assignment (expression has type "A" (type object), variable has type "A")
z = A, # E: Incompatible types in assignment (expression has type "Tuple[A]", variable has type "A")
Looks like mypy formats class type in three ways: T
(which is wrong), T (type object)
, and def () -> T
. In some cases these errors are unclear.