Skip to content

Commit 5712279

Browse files
committed
Update dataclass documentation for new __eq__ behavior in 3.13 and add tests
1 parent ada26a9 commit 5712279

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Doc/library/dataclasses.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,19 @@ Module contents
105105
- *eq*: If true (the default), an :meth:`~object.__eq__` method will be
106106
generated.
107107

108+
This method compares the class by comparing each field in order. Both
109+
instances in the comparison must be of the identical type.
110+
108111
.. versionchanged:: 3.13
109112
The generated ``__eq__`` method now compares each field individually
110113
(for example, ``self.a == other.a and self.b == other.b``), rather than
111114
comparing tuples of fields as in previous versions.
112115

113-
This method compares the class by comparing each field in order. Both
114-
instances in the comparison must be of the identical type.
115-
116116
In Python 3.12 and earlier, the comparison was performed by creating
117117
tuples of the fields and comparing them (for example,
118118
``(self.a, self.b) == (other.a, other.b)``).
119119

120-
If the class already defines :meth:`!__eq__`, this parameter is
121-
ignored.
120+
If the class already defines :meth:`!__eq__`, this parameter is ignored.
122121

123122
- *order*: If true (the default is ``False``), :meth:`~object.__lt__`,
124123
:meth:`~object.__le__`, :meth:`~object.__gt__`, and :meth:`~object.__ge__` methods will be

0 commit comments

Comments
 (0)