[issue41905] add update_abstractmethods function to update an ABC's abstract methods

Guido van Rossum report at bugs.python.org
Sat Oct 3 11:43:43 EDT 2020


Guido van Rossum <guido at python.org> added the comment:

Ah, okay. I wasn't familiar with @total_ordering so I assumed differently.  Sorry for the continued misunderstanding.

Perhaps we should just leave it alone completely then, since ISTM that any change to its implementation may cause subtle bugs in currently working code.

The problem you see only occurs when there are abstract ordering methods present. The cure is simple, just implement all four comparison functions (and do away with @total_ordering). This is not a great burden. Instead we should probably add a line or two to the docs explaining how it interacts with ABCs defining abstract ordering methods.

@dataclass uses a different approach ("is it defined in the current class?"). That is perfectly ready for a call to abc.update_abstractmethods(). (I checked, and dataclasses already depends on abc, indirectly via functools, so the extra import is free.)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41905>
_______________________________________


More information about the Python-bugs-list mailing list