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
False positives when overriding attributes in superclasses defined with function definitions #17513
When overriding an attribute created with a function definition statement in the superclass, subclasses complain about type mismatch of the function definition type itself, instead of the entire statement (that is, with all the decorators applied). See mypy Playground:
classA:
@strdefattr(self, /) ->None: ...
classB(A):
attr: str# mypy: Incompatible types in assignment (expression has type "str", base class "A" defined the type as "Callable[[A], None]") [assignment]
This is an artificial but minimum example; the actual use case is for a custom descriptor which has similar flexibility to builtins.property, allowing declaration & definition with both decorators (like @property) and assignments (like attr = property(...)).
Expected Behavior
No issues
Your Environment
Mypy version used: 1.10.1, master
Mypy command-line flags: None
Mypy configuration options from mypy.ini (and other config files): None
Activity
Use checkmember.py to check variable overrides (python#18847)