[flake8-simplify] Detect unnecessary None default for additional key expression types (SIM910)#20343
Conversation
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| SIM910 | 6 | 6 | 0 | 0 | 0 |
ntBre
left a comment
There was a problem hiding this comment.
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.
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.
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.
(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