mirror of
https://github.com/astral-sh/ruff
synced 2026-01-22 22:10:48 -05:00
Treat attribute constants as constant for yoda-conditions (#2266)
Accessed attributes that are Python constants should be considered for yoda-conditions ```py ## Error JediOrder.YODA == age # SIM300 ## OK age == JediOrder.YODA ``` ~~PS: This PR will fail CI, as the `main` branch currently failing.~~
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
YODA == age # SIM300
|
||||
YODA > age # SIM300
|
||||
YODA >= age # SIM300
|
||||
JediOrder.YODA == age # SIM300
|
||||
|
||||
# OK
|
||||
compare == "yoda"
|
||||
@@ -22,3 +23,4 @@ age == YODA
|
||||
age < YODA
|
||||
age <= YODA
|
||||
YODA == YODA
|
||||
age == JediOrder.YODA
|
||||
|
||||
Reference in New Issue
Block a user