Docs
Python docs (version 3.8):
The above example defines a read-only property; you can also define a read-write abstract property by appropriately marking one or more of the underlying methods as abstract:
class C(ABC):
@property
def x(self):
...
@x.setter
@abstractmethod
def x(self, val):
...
If only some components are abstract, only those components need to be updated to create a concrete property in a subclass:
My Code
from abc import ABC, abstractmethod
class C(ABC):
@property
def x(self):
...
@x.setter
@abstractmethod
def x(self, val):
...
class D(C):
@property
def x(self):
pass
d = D()
Expected behaviour: Fails to instantiate because there are undefined abstract methods
Actual behaviour: Instantiates without error
Question
Why doesn't this fail to instantiate? How do I write this so it does fail to instantiate if no setter is implemented in the derived class. The docs seems to indicate that this should be a covered use-case for abstractmethod. The docs also provide an example where both the getter and the setter are abstract methods which is what I'm aiming for.
Reference: https://docs.python.org/3.8/library/abc.html#abc.abstractproperty