Skip to content

Update dataclass documentation for new behavior of __eq__ in 3.13. #138991

@ericvsmith

Description

@ericvsmith

The existing documentation says "This method compares the class as if it were a tuple of its fields, in order."

However, in 3.13 the behavior was changed to compare a field at a time, such as self.a == other.a and self.b == other.b, instead of the older (self.a, self.b) == (other.a, other.b).

Any change should include a version changed notice, and a description of the 3.12 and earlier behavior, which was indeed to create a tuple of fields and compare tuples.

And if we're going to document this, we should add a test about it. Specifically, see #120645 and #128294 for examples.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions