-
-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't use hash
to avoid attrs warning
#3054
Conversation
`unsafe_hash` is an alias for `hash` as of attrs v22.2.0
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3054 +/- ##
=======================================
Coverage 99.63% 99.63%
=======================================
Files 120 120
Lines 17832 17832
Branches 3204 3204
=======================================
Hits 17767 17767
Misses 46 46
Partials 19 19
|
I'm sure none of our code actually needs this argument, we should be using just eq=false or frozen=true to get the behavior we need. These were all put in before attrs was giving clear guidance on the feature. Surely the tests all pass if you just remove the hash=false text? |
No idea, haven't tested that, but I was trying to avoid changing functionality. |
Yeah given attrs says:
it's probably a good idea to not use the parameter. And it looks like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to removing all unsafe_hash=False
s, can you add a newsfragment? You added a tag not to, but I think it's a good thing to talk about for people just reading the changelogs.
EDIT: also, could you bump attrs in the locked test requirements so we can be sure there's no other warnings?
unsafe_hash
instead of hash
to avoid attrs warninghash
to avoid attrs warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good @A5rocks
Let's let others check this, I'll only make a release tomorrow anyways. |
Yea mostly commenting on the additional changes you made |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I need this for AnyIO to pass its test suite on 3.13 😃 |
Whoa, y'all are fast! I ran into the warning in stamina and wanted to reach out to you how obnoxious it is for you and if I should just soft-deprecate it instead. Looks like you got most of them except (at least) Line 142 in 223e4f4
A fun fact on the side: attrs's guidance on hashing goes entirely back to @njsmith opening my eyes and causing a big rewrite of that feature within attrs. So the chances are excellent that you don't need the argument at all. Tangentially, |
We've already handled it and it's been fine: it revealed two configuration issues so that's nice! (one is that deprecation warnings get ignored if the module is imported as a plugin first, the other is that one of the CI runs should use |
Unfortunate, surprised CI didn't catch that, but this is because when I made this pull request I did |
I did grepped later for hash= and found only this one instance so I think you’ll be fine! |
Fixes #3053, this pull request replaces all uses of
@attrs.define(... hash=x)
with@attrs.define(... unsafe_hash=x)
.In attrs >= 24.1.0, a warning is raised that
hash
is going to be removed in August of 2025.unsafe_hash
is an alias forhash
as of attrs v22.2.0, so there should be no functional changes.