-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
add autofix for PIE804
#7884
add autofix for PIE804
#7884
Conversation
key.as_constant_expr() | ||
.unwrap() | ||
.value | ||
.as_str() | ||
.unwrap() | ||
.value, |
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.
not particularly proud of this, is there a less scary-looking way to do this?
a36b277
to
8d6dd2c
Compare
let kwargs = keys | ||
.iter() | ||
.filter_map(|key| key.as_ref().and_then(as_kwarg)) | ||
.collect::<Vec<_>>(); |
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.
I restructured it such that, when we validate the keyword arguments, we also return the valid keyword argument name. That lets us avoid a bunch of unwraps below. In other words: when we validate, we return the validated data.
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.
ooo. Love it! Thanks!
## Summary `foo(**{})` was an overlooked edge case for `PIE804` which introduced a crash within the Fix, introduced in #7884. I've made it so that `foo(**{})` turns into `foo()` when applied with `--fix`, but is that desired/expected? 🤔 Should we just ignore instead? ## Test Plan `cargo test`
Summary
Adds autofix for
PIE804
, closes #6783.I've split the
if
s apart to make the diagnostics easier to read. Open to suggestions if that's not desired!Test Plan
cargo test
, and manually.