import abc
class A(abc.ABC):
@classmethod
@property
@abc.abstractmethod
def type(cls):
raise NotImplementedError
class B(A, metaclass=abc.ABCMeta):
@abc.abstractmethod
def other(self):
raise NotImplementedError
class C(B):
@classmethod
@property
def type(cls):
return 'C'
def other(self):
print('other')
c = C()
c.other()
This script is failing with an NotImplementedError:
Traceback (most recent call last):
File "C:\Users\Justin Baudisch\Desktop\test.py", line 10, in <module>
class B(A, metaclass=abc.ABCMeta):
File "C:\Program Files\Python310\lib\abc.py", line 107, in __new__
_abc_init(cls)
File "C:\Users\Justin Baudisch\Desktop\test.py", line 8, in type
raise NotImplementedError
NotImplementedError
So the script executes the "type"-property. But why? This is not the expected behaviour (?).
If I remove the @property decorator and leave it as a method, it works fine. Same when I remove the @classmethod decorator.
Your environment
CPython versions tested on: Python 3.10
Operating system and architecture: Windows 11
The text was updated successfully, but these errors were encountered:
Bug report
This script is failing with an NotImplementedError:
So the script executes the "type"-property. But why? This is not the expected behaviour (?).
If I remove the
@property
decorator and leave it as a method, it works fine. Same when I remove the@classmethod
decorator.Your environment
The text was updated successfully, but these errors were encountered: