Merged
Conversation
diceroll123
commented
Oct 10, 2023
Comment on lines
+87
to
+92
| key.as_constant_expr() | ||
| .unwrap() | ||
| .value | ||
| .as_str() | ||
| .unwrap() | ||
| .value, |
Contributor
Author
There was a problem hiding this comment.
not particularly proud of this, is there a less scary-looking way to do this?
Contributor
a36b277 to
8d6dd2c
Compare
| let kwargs = keys | ||
| .iter() | ||
| .filter_map(|key| key.as_ref().and_then(as_kwarg)) | ||
| .collect::<Vec<_>>(); |
Member
There was a problem hiding this comment.
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.
Contributor
Author
There was a problem hiding this comment.
ooo. Love it! Thanks!
konstin
pushed a commit
that referenced
this pull request
Oct 11, 2023
charliermarsh
pushed a commit
that referenced
this pull request
Oct 11, 2023
## 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`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds autofix for
PIE804, closes #6783.I've split the
ifs apart to make the diagnostics easier to read. Open to suggestions if that's not desired!Test Plan
cargo test, and manually.