You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fails type-checking using mypy==0.550.0 and Python 3.6 with the following error:
Incompatible types in assignment (expression has type "Type[object]", variable has type "Union[Type[B], Type[C]]")
The "use the common base class" as the type is probably a good heuristic in general, but it seems weird that an explicit type annotation with a union fails.
(The context for this is that we have two classes that both implement an ABC interface. At runtime, we switch between them based on some configuration and environment variables, but because MyPy infers the class type as the ABC, we get a Cannot instantiate abstract class error).
The text was updated successfully, but these errors were encountered:
alanhdu
changed the title
MyPy type inference too general
MyPy type inference clashes with type annotation
Nov 29, 2017
The following code:
fails type-checking using
mypy==0.550.0
and Python 3.6 with the following error:The "use the common base class" as the type is probably a good heuristic in general, but it seems weird that an explicit type annotation with a union fails.
(The context for this is that we have two classes that both implement an ABC interface. At runtime, we switch between them based on some configuration and environment variables, but because MyPy infers the class type as the ABC, we get a
Cannot instantiate abstract class
error).The text was updated successfully, but these errors were encountered: