I hope this question is not too basic. Consider the case in which I want to provide a Protocol with a default implementation that performs some action on the setter of one of its properties (so it is not simply declaring an attribute):
class MyProtocol(Protocol):
@property
def my_property(self) -> int:
return self._my_property
@my_property.setter
def my_property(self, value: int) -> None:
do_something(value)
self._my_property = value
Here Mypy complains because self._my_property is not part of the Protocol. Is there an accepted way to achieve this?