-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
The following example generates a confusing error message, since it's unclear which Any type it is referring to:
class Any: pass
x = Any()
x = 1 # Incompatible types in assignment
# (expression has type "int", variable has type "Any")(It would be more confusing if the Any type is inferred from the return type of a function.)
It would be better to always use a fully qualified name for a class named Any in error messages (similarly also for None, Union, etc.).
This can also happen with classes that have names resembling built-in types:
class float: pass
x = float()
x = 0 # Incompatible types in assignment
# (expression has type "int", variable has type "float")The relevant code seems to be in mypy.messages.format_type.