From e40f5f901dc6b71ae4382dbe3b9f7b5384cf8a64 Mon Sep 17 00:00:00 2001 From: Josh Cannon Date: Fri, 28 Jul 2023 10:41:29 -0500 Subject: [PATCH 1/7] Mention slots pitfall in dataclass docs --- Doc/library/dataclasses.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst index 535a60ccca8d07..1220a6b6361e90 100644 --- a/Doc/library/dataclasses.rst +++ b/Doc/library/dataclasses.rst @@ -185,7 +185,10 @@ Module contents - ``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. If :attr:`~object.__slots__` is already defined in the class, then :exc:`TypeError` - is raised. + is raised. Calling no-arg `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`. + See :issue:`46404` for full details. .. versionadded:: 3.10 From e9930d7c7f8c0e799e678c6dbdf1336f18f534de Mon Sep 17 00:00:00 2001 From: Josh Cannon Date: Fri, 28 Jul 2023 10:53:18 -0500 Subject: [PATCH 2/7] Update dataclasses.rst --- Doc/library/dataclasses.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst index 1220a6b6361e90..e676d01efd8321 100644 --- a/Doc/library/dataclasses.rst +++ b/Doc/library/dataclasses.rst @@ -188,7 +188,7 @@ Module contents is raised. Calling no-arg `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`. - See :issue:`46404` for full details. + The two-arg `super()` is a valid workaround. See :issue:`46404` for full details. .. versionadded:: 3.10 From 91bbbd2b08ff6c7ea3550615bfa96710ca4ccdcc Mon Sep 17 00:00:00 2001 From: Josh Cannon Date: Fri, 28 Jul 2023 10:56:38 -0500 Subject: [PATCH 3/7] Update dataclasses.rst --- Doc/library/dataclasses.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst index e676d01efd8321..a94ae165f79b84 100644 --- a/Doc/library/dataclasses.rst +++ b/Doc/library/dataclasses.rst @@ -186,7 +186,7 @@ Module contents will be generated and new class will be returned instead of the original one. If :attr:`~object.__slots__` is already defined in the class, then :exc:`TypeError` is raised. Calling no-arg `super()` in dataclasses using `slots=True` will result in - the following Exception being raised: + the following Exception being raised: `TypeError: super(type, obj): obj must be an instance or subtype of type`. The two-arg `super()` is a valid workaround. See :issue:`46404` for full details. From 08903c5bd29c8e65c0c8568c1c4a4bc810d0711c Mon Sep 17 00:00:00 2001 From: Josh Cannon Date: Fri, 28 Jul 2023 11:16:42 -0500 Subject: [PATCH 4/7] Double trouble --- Doc/library/dataclasses.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst index a94ae165f79b84..9af201940c2cdf 100644 --- a/Doc/library/dataclasses.rst +++ b/Doc/library/dataclasses.rst @@ -185,10 +185,10 @@ Module contents - ``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. If :attr:`~object.__slots__` is already defined in the class, then :exc:`TypeError` - is raised. Calling no-arg `super()` in dataclasses using `slots=True` will result in + is raised. Calling no-arg ``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 `super()` is a valid workaround. See :issue:`46404` for full details. + ``TypeError: super(type, obj): obj must be an instance or subtype of type``. + The two-arg ``super()`` is a valid workaround. See :issue:`46404` for full details. .. versionadded:: 3.10 From fdff6b509bfb439f87a5dbba2d34e6aa78251d07 Mon Sep 17 00:00:00 2001 From: Josh Cannon Date: Mon, 7 Aug 2023 12:02:25 -0500 Subject: [PATCH 5/7] Update Doc/library/dataclasses.rst Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- Doc/library/dataclasses.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst index 9af201940c2cdf..1fdbc90f6a510d 100644 --- a/Doc/library/dataclasses.rst +++ b/Doc/library/dataclasses.rst @@ -188,7 +188,7 @@ Module contents is raised. Calling no-arg ``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 ``super()`` is a valid workaround. See :issue:`46404` for full details. + The two-arg ``super()`` is a valid workaround. See :gh:`90562` for full details. .. versionadded:: 3.10 From 173d4b1deeed1353a4133fd43b1a7b84edd6cdb2 Mon Sep 17 00:00:00 2001 From: Josh Cannon Date: Tue, 12 Mar 2024 16:33:16 -0500 Subject: [PATCH 6/7] Update Doc/library/dataclasses.rst Co-authored-by: Jelle Zijlstra --- Doc/library/dataclasses.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst index deb4ec2fca543c..6f21c7acfb5129 100644 --- a/Doc/library/dataclasses.rst +++ b/Doc/library/dataclasses.rst @@ -185,10 +185,10 @@ Module contents - ``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. If :attr:`~object.__slots__` is already defined in the class, then :exc:`TypeError` - is raised. Calling no-arg ``super()`` in dataclasses using ``slots=True`` will result in + 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 ``super()`` is a valid workaround. See :gh:`90562` for full details. + The two-arg :func:`super` is a valid workaround. See :gh:`90562` for full details. .. versionadded:: 3.10 From 42606c305708697793d989677fbe35cdb96399f4 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 21 May 2024 06:05:49 -0600 Subject: [PATCH 7/7] Update Doc/library/dataclasses.rst --- Doc/library/dataclasses.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst index 0f16b5335e80ee..027fd5378fc52c 100644 --- a/Doc/library/dataclasses.rst +++ b/Doc/library/dataclasses.rst @@ -186,7 +186,7 @@ Module contents 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` is raised. Calling no-arg :func:`super` in dataclasses using ``slots=True`` will result in - the following Exception being raised: + 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.