[issue20897] @abstractmethod does not enforce method signatures
Eric Snow
report at bugs.python.org
Tue Mar 18 15:14:01 CET 2014
Eric Snow added the comment:
Both abstractnethod and abstractproperty work by setting __isabstractmethod__ to True on the decorated function. Then type.__new__ looks for any attributes of the current class (including inherited ones) that have __isabstractmethod__ set to True. The signature of abstract methods is not checked/enforced. In fact the overriding attribute doesn't even have to be a method at all. PEP 3119 doesn't say much about this. I expect it is the way the way it is for performance reasons.
As to SuperSubber working in Python 3, don't forget that metaclasses are declared in the class signature:
class SuperSubber(META):
pass
Doing things like enforcing signatures is doable, but would require some other mechanism. If you want to pursue this further I recommend you take it to the python-ideas mailing list.
----------
nosy: +eric.snow
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20897>
_______________________________________
More information about the Python-bugs-list
mailing list