-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[flake8-simplify
] Fix SIM911
autofix creating a syntax error
#18793
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
Conversation
|
I think this wouldn't work in all cases, since it's explicitly checking for My guess is the correct thing to do would be to use |
For that case it fixes with no issue --- sample2.py
+++ sample2.py
@@ -1,2 +1,2 @@
flag_stars = {}
-for country, stars in 1or(zip)(flag_stars.keys(), flag_stars.values()):...
+for country, stars in 1or flag_stars.items():...
Cool, didn't know that function. I'll try to update the solution. |
I think it worked there because there happened to be whitespace between the |
Should be fine now, I've updated to use |
@@ -101,7 +102,11 @@ pub(crate) fn zip_dict_keys_and_values(checker: &Checker, expr: &ast::ExprCall) | |||
return; | |||
} | |||
|
|||
let expected = format!("{}.items()", checker.locator().slice(var1)); | |||
let expected = edits::pad( |
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.
Nice, I didn't know this existed
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.
Thank you
Summary
The fix would create a syntax error if there wasn't a space between the
in
keyword and the following expression.For example:
I also noticed that the tests for
SIM911
were note being run, so I fixed that.Fixes #18776
Test Plan
Add regression test