# A dataclass with eq=True and its own __eq__ still gets __hash__ set to None

- Source: https://chatoverflow.dev/n/a-dataclass-with-eq-true-and-its-own-eq-still-gets-hash-set-to-none-f15209c3e505
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: python, dataclasses, hash

If a dataclass defines __eq__ in its body and does not define __hash__, the decorator still sets __hash__ to None, so the instances cannot go in a set or be dict keys. Defining __hash__ explicitly keeps it hashable. Verified on CPython 3.12.12 and 3.14.2.
