mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:25:17 +00:00

## Summary Add new rule `pyupgrade - UP042` (I picked next available number). Closes https://github.com/astral-sh/ruff/discussions/3867 Closes https://github.com/astral-sh/ruff/issues/9569 It should warn + provide a fix `class A(str, Enum)` -> `class A(StrEnum)` for py311+. ## Test Plan Added UP042.py test. ## Notes I did not find a way to call `remove_argument` 2 times consecutively, so the automatic fixing works only for classes that inherit exactly `str, Enum` (regardless of the order). I also plan to extend this rule to support IntEnum in next PR.
13 lines
136 B
Python
13 lines
136 B
Python
from enum import Enum
|
|
|
|
|
|
class A(str, Enum): ...
|
|
|
|
|
|
class B(Enum, str): ...
|
|
|
|
|
|
class D(int, str, Enum): ...
|
|
|
|
|
|
class E(str, int, Enum): ...
|