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 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
Python version used: 3.10, 3.12
The text was updated successfully, but these errors were encountered:
Bug Report, To Reproduce, & Actual Behaviour
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:
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 (likeattr = property(...)
).Expected Behavior
No issues
Your Environment
mypy.ini
(and other config files): NoneThe text was updated successfully, but these errors were encountered: