[issue46382] dataclass(slots=True) does not account for slots in base classes
Arie Bovenberg
report at bugs.python.org
Sat Jan 15 02:33:17 EST 2022
Arie Bovenberg <a.c.bovenberg at gmail.com> added the comment:
There are already 2 complexities I can think of:
1. This behavior may break some people's code, if they use __slots__ to iterate over
the fields of a dataclass. Solution: explicitly mention in the docs that
not every field may get a slot on the new class. Advise them to use
`fields()` to iterate over the fields.
2. It's technically allowed for __slots__ to be an iterator (which will then be
exhausted at class creation). Finding the __slots__ of such a class
may require more elaborate introspection.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46382>
_______________________________________
More information about the Python-bugs-list
mailing list