You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes#16550
Improve hashability detection for attrs classes.
I added a new parameter to `add_attribute_to_class`,
`overwrite_existing`, since I needed it.
Frozen classes remain hashable, non-frozen default to no. This can be
overriden by passing in `hash=True` or `unsafe_hash=True` (new
parameter, added to stubs) to `define()`.
Inheritance-wise I think we're correct, if a non-hashable class inherits
from a hashable one, it's still unhashable at runtime.
Accompanying tests.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Looks like non-frozen attrs classes are considered hashable by default. But they aren't.
The following snippet type-checks but explodes at runtime:
(The behavior can be customized.)
This might be an easy one to fix. I can grab it when I have time, or it may be an easy first issue for someone?
The text was updated successfully, but these errors were encountered: