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
{{ message }}
Repository navigation
Class attribute that duplicates a base class attribute is not flagged #1338
Mypy should verify that class attributes are compatible with any definitions in a base class. The latter is clearly a bug. The first one should be disallowed as well, for consistency with other variable definitions. However, just an assignment without a declared type should be okay even if the attribute is defined in a base class, but mypy should verify that the assigned value is compatible with the base class definition.
I wonder if it's worth a note or warning if you redefine an attribute (with the same type) in a subclass? When seen as documentation, I found this confusing.
Activity
JukkaL commentedon Apr 7, 2016
Mypy should verify that class attributes are compatible with any definitions in a base class. The latter is clearly a bug. The first one should be disallowed as well, for consistency with other variable definitions. However, just an assignment without a declared type should be okay even if the attribute is defined in a base class, but mypy should verify that the assigned value is compatible with the base class definition.
gvanrossum commentedon Apr 7, 2016
I wonder if it's worth a note or warning if you redefine an attribute (with the same type) in a subclass? When seen as documentation, I found this confusing.
For class variables, lookup type in base classes (#1338, #2022, #2211) (
Revert "For class variables, lookup type in base classes (#1338, #2022,
Revert "For class variables, lookup type in base classes (#1338, #2022,
For class variables, lookup type in base classes (#1338, #2022, #2211) (
gvanrossum commentedon Jan 27, 2017
Fixed by #2510.