mirror of
https://github.com/python/cpython.git
synced 2025-09-25 01:43:11 +00:00
gh-90562: Mention slots pitfall in dataclass docs (#107391)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Erlend E. Aasland <erlend@python.org> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
parent
10b1bd926a
commit
e3ed574f6a
1 changed files with 4 additions and 1 deletions
|
@ -185,7 +185,10 @@ Module contents
|
||||||
- *slots*: If true (the default is ``False``), :attr:`~object.__slots__` attribute
|
- *slots*: If true (the default is ``False``), :attr:`~object.__slots__` attribute
|
||||||
will be generated and new class will be returned instead of the original one.
|
will be generated and new class will be returned instead of the original one.
|
||||||
If :attr:`!__slots__` is already defined in the class, then :exc:`TypeError`
|
If :attr:`!__slots__` is already defined in the class, then :exc:`TypeError`
|
||||||
is raised.
|
is raised. Calling no-arg :func:`super` in dataclasses using ``slots=True`` will result in
|
||||||
|
the following exception being raised:
|
||||||
|
``TypeError: super(type, obj): obj must be an instance or subtype of type``.
|
||||||
|
The two-arg :func:`super` is a valid workaround. See :gh:`90562` for full details.
|
||||||
|
|
||||||
.. versionadded:: 3.10
|
.. versionadded:: 3.10
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue