Better communicate dataclass mutable default check change in Python 3.11

GitHub PR #29867 changed dataclasses’ check for mutable field default hard-coded list/set/dict to anything with __hash__ = None. This allowed non-mutable subclasses of these built-ins, but disallows any custom types that didn’t set __hash__.

This is easy to support[1], but I didn’t know it was a problem until after I tested my library with Python 3.11 (at which point the docs said how to fix). I propose to bring more attention to this change by including it in the what’s new page. Right now, it’s buried in the change log.

  1. for my pseudo-immutable object with __slots__ = (), define def __hash__(slf): return 42 ↩︎

Good idea, the devguide says:

If the change is particularly interesting for end users (e.g. new features, significant improvements, or backwards-incompatible changes), then an entry in the What's New in Python document (in Doc/whatsnew/ ) should be added as well.

Would you like to create a PR to add it?

Here’s the What’s New page to edit and more info on docs:

1 Like

Done: Add dataclass field default change by EpicWink · Pull Request #96790 · python/cpython · GitHub