File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,6 +24,31 @@ def my_abstract_method(self, ...):
2424 return funcobj
2525
2626
27+ class abstractproperty (property ):
28+ """A decorator indicating abstract properties.
29+
30+ Requires that the metaclass is ABCMeta or derived from it. A
31+ class that has a metaclass derived from ABCMeta cannot be
32+ instantiated unless all of its abstract properties are overridden.
33+
34+ Usage:
35+
36+ class C(metaclass=ABCMeta):
37+ @abstractproperty
38+ def my_abstract_property(self):
39+ ...
40+
41+ This defines a read-only property; you can also define a read-write
42+ abstract property using the 'long' form of property declaration:
43+
44+ class C(metaclass=ABCMeta):
45+ def getx(self): ...
46+ def setx(self, value): ...
47+ x = abstractproperty(getx, setx)
48+ """
49+ __isabstractmethod__ = True
50+
51+
2752class _Abstract (object ):
2853
2954 """Helper class inserted into the bases by ABCMeta (using _fix_bases()).
You can’t perform that action at this time.
0 commit comments