-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[flake8-simplify] Detect unnecessary None default for additional key expression types (SIM910)
#20343
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
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| SIM910 | 6 | 6 | 0 | 0 | 0 |
ntBre
left a comment
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! Sorry for the hassle, but could you preview gate this too? This is a pretty big expansion in scope since it was restricted to only two types of expressions before.
ntBre
left a comment
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! I just pushed one quick commit recombining the two test files. It makes it a little easier to stabilize later if we're already running the tests on both stable and preview.
| # Complex expression as key | ||
| ages = {"Tom": 23, "Maria": 23, "Dog": 11} | ||
| key = "Tom" if True else "Maria" | ||
| age = ages.get(key, None) |
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.
This is actually just another Expr::Name as key since it's assigned to a variable. Even the if expression itself is only a single Expr::If, but this is fine either way!
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 inlined this too while I was at it)
flake8-simplify] Detect unnecessary None default when key is a method call (SIM910)flake8-simplify] Detect unnecessary None default for additional key expression types (SIM910)
Summary
Fixes #20341