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
A dataclass containing a Callable field doesn't match the protocol. On the other hand if the field is defined using a callback protocol (another protocol with __call__) or the class is not a dataclass, no error is reported.
test.py:26: error: Incompatible types in assignment (expression has type "FooDC", variable has type "FooProto") [assignment]
test.py:26: note: Protocol member FooProto.f expected settable variable, got read-only attribute
The mypy's subtypes.py:get_member_flags() function contains:
ifv.is_property:
return {IS_VAR}
which doesn't take the v.is_settable_property into account while it is set for Callables in plugins/dataclasses.py:_propertize_callables().
Bug Report
A dataclass containing a
Callable
field doesn't match the protocol. On the other hand if the field is defined using a callback protocol (another protocol with__call__
) or the class is not a dataclass, no error is reported.The mypy's
subtypes.py:get_member_flags()
function contains:which doesn't take the
v.is_settable_property
into account while it is set for Callables inplugins/dataclasses.py:_propertize_callables()
.To Reproduce
https://mypy-play.net/?mypy=latest&python=3.12&gist=5c77ed1a30b03cba5cf0ba8e710a4214
Expected Behavior
I expect a dataclass with a
Callable
to match the protocol.Actual Behavior
The dataclass doesn't match the protocol.
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: