[New-bugs-announce] [issue41905] add update_abstractmethods function to update an ABC's abstract methods

Ben Avrahami report at bugs.python.org
Thu Oct 1 11:54:52 EDT 2020


New submission from Ben Avrahami <avrahami.ben at gmail.com>:

python-ideas discussion:
https://mail.python.org/archives/list/python-ideas@python.org/thread/6BNJ3YSEBPHEPGXSAZGBW3TJ64ZGZIHE/

In order to allow "decorator mixins" (most notably dataclass and total_ordering) to implement ABCs, new functionality is needed. I propose a new python function in `abc.py` called `update_abstractmethods`. The function will accept a class and, if the class is an instance of ABCMeta, will update the class's `__abstractmethods__` attribute to not include implemented attributes, and to include new abstractmethods (proposed implementation in thread).

Both dataclass and total_ordering will be modified to call this function on the subject class before returning it, and 3rd-party libraries which implement mixin decorators (like attrs) will be to do the same.

Also, the function can be used as a decorator individually, this is especially useful in cases where 3rd party decorators do not call the function.

----------
components: Library (Lib)
messages: 377769
nosy: avrahami.ben
priority: normal
severity: normal
status: open
title: add update_abstractmethods function to update an ABC's abstract methods
type: enhancement
versions: Python 3.10

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


More information about the New-bugs-announce mailing list