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
When an override is incompatible with the base class, mypy only shows the short name of the base class (e.g. MyClass). Change that to show the full name (e.g. pkg.mod.MyClass) when the base class is defined in a different module.
b.py:4: error: Argument 1 of "f" is incompatible with supertype "A"; supertype defines the argument type as "int" [override]
b.py:4: note: This violates the Liskov substitution principle
b.py:4: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
b.py:6: error: Signature of "g" incompatible with supertype "A" [override]
b.py:6: note: Superclass:
b.py:6: note: def g(self) -> None
b.py:6: note: Subclass:
b.py:6: note: def g(self, x: str) -> None
The desired output would be ... with supertype "a.A" ... instead of ... with supertype "A" ....
Pitch
There can be a complex class hierarchy, and different base classes in the MRO can be in different modules. Currently finding the base class of the method is inconvenient, especially for somebody not using an IDE that allows them to quickly look it up. Also, it's not uncommon to have multiple classes with the same short name, so the current message is ambiguous.
The text was updated successfully, but these errors were encountered:
Feature
When an override is incompatible with the base class, mypy only shows the short name of the base class (e.g.
MyClass
). Change that to show the full name (e.g.pkg.mod.MyClass
) when the base class is defined in a different module.Example where this would make a difference:
This is the current output:
The desired output would be
... with supertype "a.A" ...
instead of... with supertype "A" ...
.Pitch
There can be a complex class hierarchy, and different base classes in the MRO can be in different modules. Currently finding the base class of the method is inconvenient, especially for somebody not using an IDE that allows them to quickly look it up. Also, it's not uncommon to have multiple classes with the same short name, so the current message is ambiguous.
The text was updated successfully, but these errors were encountered: