Make SIM401 catch ternary operations#7415
Merged
charliermarsh merged 4 commits intoastral-sh:mainfrom Oct 20, 2023
Merged
Conversation
6c53ca1 to
da38373
Compare
da38373 to
720d476
Compare
Contributor
PR Check ResultsEcosystemℹ️ ecosystem check detected changes. (+3, -1, 0 error(s)) rotki (+3, -1)
- [*] 11 fixable with the `--fix` option (223 hidden fixes can be enabled with the `--unsafe-fixes` option). + [*] 11 fixable with the `--fix` option (225 hidden fixes can be enabled with the `--unsafe-fixes` option). + rotkehlchen/db/updates.py:204:27: SIM401 Use `rule_data.get('links', {})` instead of an `if` block + rotkehlchen/externalapis/cryptocompare.py:327:24: SIM401 Use `json_ret.get('Data', json_ret)` instead of an `if` block
|
dhruvmanila
reviewed
Sep 18, 2023
konstin
reviewed
Sep 18, 2023
Comment on lines
+1033
to
+1041
| let node = orelse.clone(); | ||
| let node1 = *test_key.clone(); | ||
| let node2 = ast::ExprAttribute { | ||
| value: expected_subscript.clone(), | ||
| attr: Identifier::new("get".to_string(), TextRange::default()), | ||
| ctx: ExprContext::Load, | ||
| range: TextRange::default(), | ||
| }; | ||
| let node3 = ast::ExprCall { |
Member
There was a problem hiding this comment.
nit: could you give them more descriptive names than node 1/2/3?
CodSpeed Performance ReportMerging #7415 will not alter performanceComparing Summary
|
a070c74 to
2334c66
Compare
Member
|
My only hesitation here is whether this should be a separate rule and / or whether it should be behind the preview flag. |
Contributor
Author
|
I've looked at |
Member
|
I'll take this one to completion -- gonna put this behavior under preview mode. |
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
Fixes #7288
Make SIM401 rules to catch ternary operations.
Test Plan
Tested against SIM401.py fixtures