Raymond Hettinger <[email protected]> added the comment:
You might be misunderstanding what @total_ordering does. It can't be used by
subclasses to override abstract methods.
>>> from abc import abstractmethod, ABC
>>> from functools import total_ordering
>>> class X(ABC):
@abstractmethod
def __lt__(self, other):
raise RuntimeError('abstract called')
>>> @total_ordering
class Y(X):
def __le__(self, other):
return True
>>> sorted(vars(Y)) # note that __lt__ is missing and Y() won't instantiate
['__abstractmethods__', '__doc__', '__ge__', '__gt__', '__le__', '__module__',
'_abc_impl']
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue41905>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com