-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add flake8-pie PIE796: prefer-unique-enum (#1923)
I accept any suggestion. By the way, I have a doubt, I have checked and all flake8-pie plugins can be fixed by ruff, but is it necessary that this one is also fixed automatically ? rel #1543
- Loading branch information
Showing
9 changed files
with
192 additions
and
0 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,54 @@ | ||
class FakeEnum(enum.Enum): | ||
A = "A" | ||
B = "B" | ||
C = "B" # PIE796 | ||
|
||
|
||
class FakeEnum2(Enum): | ||
A = 1 | ||
B = 2 | ||
C = 2 # PIE796 | ||
|
||
|
||
class FakeEnum3(str, Enum): | ||
A = "1" | ||
B = "2" | ||
C = "2" # PIE796 | ||
|
||
class FakeEnum4(Enum): | ||
A = 1.0 | ||
B = 2.5 | ||
C = 2.5 # PIE796 | ||
|
||
|
||
class FakeEnum5(Enum): | ||
A = 1.0 | ||
B = True | ||
C = False | ||
D = False # PIE796 | ||
|
||
|
||
class FakeEnum6(Enum): | ||
A = 1 | ||
B = 2 | ||
C = None | ||
D = None # PIE796 | ||
|
||
|
||
@enum.unique | ||
class FakeEnum7(enum.Enum): | ||
A = "A" | ||
B = "B" | ||
C = "C" | ||
|
||
@unique | ||
class FakeEnum8(Enum): | ||
A = 1 | ||
B = 2 | ||
C = 2 # PIE796 | ||
|
||
class FakeEnum9(enum.Enum): | ||
A = "A" | ||
B = "B" | ||
C = "C" | ||
|
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 |
---|---|---|
|
@@ -1431,6 +1431,7 @@ | |
"PIE79", | ||
"PIE790", | ||
"PIE794", | ||
"PIE796", | ||
"PIE8", | ||
"PIE80", | ||
"PIE807", | ||
|
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
75 changes: 75 additions & 0 deletions
75
src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE796_PIE796.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,75 @@ | ||
--- | ||
source: src/rules/flake8_pie/mod.rs | ||
expression: diagnostics | ||
--- | ||
- kind: | ||
PreferUniqueEnums: "\"B\"" | ||
location: | ||
row: 4 | ||
column: 4 | ||
end_location: | ||
row: 4 | ||
column: 11 | ||
fix: ~ | ||
parent: ~ | ||
- kind: | ||
PreferUniqueEnums: "2" | ||
location: | ||
row: 10 | ||
column: 4 | ||
end_location: | ||
row: 10 | ||
column: 9 | ||
fix: ~ | ||
parent: ~ | ||
- kind: | ||
PreferUniqueEnums: "\"2\"" | ||
location: | ||
row: 16 | ||
column: 4 | ||
end_location: | ||
row: 16 | ||
column: 11 | ||
fix: ~ | ||
parent: ~ | ||
- kind: | ||
PreferUniqueEnums: "2.5" | ||
location: | ||
row: 21 | ||
column: 4 | ||
end_location: | ||
row: 21 | ||
column: 11 | ||
fix: ~ | ||
parent: ~ | ||
- kind: | ||
PreferUniqueEnums: "False" | ||
location: | ||
row: 28 | ||
column: 4 | ||
end_location: | ||
row: 28 | ||
column: 13 | ||
fix: ~ | ||
parent: ~ | ||
- kind: | ||
PreferUniqueEnums: None | ||
location: | ||
row: 35 | ||
column: 4 | ||
end_location: | ||
row: 35 | ||
column: 12 | ||
fix: ~ | ||
parent: ~ | ||
- kind: | ||
PreferUniqueEnums: "2" | ||
location: | ||
row: 48 | ||
column: 4 | ||
end_location: | ||
row: 48 | ||
column: 9 | ||
fix: ~ | ||
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