Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement duplicate isinstance detection (SIM101) (#1673)
See: #998.
- Loading branch information
1 parent
04111da
commit 75bb6ad
Showing
9 changed files
with
284 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
if isinstance(a, int) or isinstance(a, float): # SIM101 | ||
pass | ||
|
||
if isinstance(a, (int, float)) or isinstance(a, bool): # SIM101 | ||
pass | ||
|
||
if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool): # SIM101 | ||
pass | ||
|
||
if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float): # SIM101 | ||
pass | ||
|
||
if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float): # SIM101 | ||
pass | ||
|
||
if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool): # SIM101 | ||
pass | ||
|
||
if isinstance(a, int) and isinstance(b, bool) or isinstance(a, float): | ||
pass | ||
|
||
if isinstance(a, bool) or isinstance(b, str): | ||
pass |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -936,6 +936,7 @@ | |
"SIM", | ||
"SIM1", | ||
"SIM10", | ||
"SIM101", | ||
"SIM102", | ||
"SIM105", | ||
"SIM107", | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
107 changes: 107 additions & 0 deletions
107
src/flake8_simplify/snapshots/ruff__flake8_simplify__tests__SIM101_SIM101.py.snap
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
--- | ||
source: src/flake8_simplify/mod.rs | ||
expression: checks | ||
--- | ||
- kind: | ||
DuplicateIsinstanceCall: a | ||
location: | ||
row: 1 | ||
column: 3 | ||
end_location: | ||
row: 1 | ||
column: 45 | ||
fix: | ||
content: "isinstance(a, (int, float))" | ||
location: | ||
row: 1 | ||
column: 3 | ||
end_location: | ||
row: 1 | ||
column: 45 | ||
parent: ~ | ||
- kind: | ||
DuplicateIsinstanceCall: a | ||
location: | ||
row: 4 | ||
column: 3 | ||
end_location: | ||
row: 4 | ||
column: 53 | ||
fix: | ||
content: "isinstance(a, (int, float, bool))" | ||
location: | ||
row: 4 | ||
column: 3 | ||
end_location: | ||
row: 4 | ||
column: 53 | ||
parent: ~ | ||
- kind: | ||
DuplicateIsinstanceCall: a | ||
location: | ||
row: 7 | ||
column: 3 | ||
end_location: | ||
row: 7 | ||
column: 68 | ||
fix: | ||
content: "isinstance(a, (int, float)) or isinstance(b, bool)" | ||
location: | ||
row: 7 | ||
column: 3 | ||
end_location: | ||
row: 7 | ||
column: 68 | ||
parent: ~ | ||
- kind: | ||
DuplicateIsinstanceCall: a | ||
location: | ||
row: 10 | ||
column: 3 | ||
end_location: | ||
row: 10 | ||
column: 68 | ||
fix: | ||
content: "isinstance(a, (int, float)) or isinstance(b, bool)" | ||
location: | ||
row: 10 | ||
column: 3 | ||
end_location: | ||
row: 10 | ||
column: 68 | ||
parent: ~ | ||
- kind: | ||
DuplicateIsinstanceCall: a | ||
location: | ||
row: 13 | ||
column: 3 | ||
end_location: | ||
row: 13 | ||
column: 68 | ||
fix: | ||
content: "isinstance(a, (int, float)) or isinstance(b, bool)" | ||
location: | ||
row: 13 | ||
column: 3 | ||
end_location: | ||
row: 13 | ||
column: 68 | ||
parent: ~ | ||
- kind: | ||
DuplicateIsinstanceCall: a | ||
location: | ||
row: 16 | ||
column: 4 | ||
end_location: | ||
row: 16 | ||
column: 46 | ||
fix: | ||
content: "isinstance(a, (int, float))" | ||
location: | ||
row: 16 | ||
column: 4 | ||
end_location: | ||
row: 16 | ||
column: 46 | ||
parent: ~ | ||
|
This file contains 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