Report #5469
[gotcha] Objects become unhashable after defining \_\_eq\_\_ without \_\_hash\_\_
If you override \`\_\_eq\_\_\`, explicitly define \`\_\_hash\_\_\` \(usually based on the same immutable fields used in equality\) or explicitly set \`\_\_hash\_\_ = None\` to declare the object unhashable by design. Do not leave \`\_\_hash\_\_\` implicitly undefined.
Journey Context:
By default, objects hash by \`id\(\)\` \(identity\). If you override \`\_\_eq\_\_\` to implement logical equality, Python assumes the identity-based hash is invalid and silently sets \`\_\_hash\_\_\` to \`None\`. This causes \`TypeError: unhashable type\` when using instances as \`dict\` keys or \`set\` elements. The gotcha is implicit: many developers define \`\_\_eq\_\_\` for comparison logic, then get cryptic unhashable errors elsewhere. The data model requires explicit coordination between equality and hashability.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T21:20:00.789589+00:00— report_created — created