mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 14:21:24 +00:00
Allow sunder names from enum.Enum
(#7987)
Closes https://github.com/astral-sh/ruff/issues/7971.
This commit is contained in:
parent
1fabaca5de
commit
134def0119
2 changed files with 13 additions and 0 deletions
|
@ -63,6 +63,11 @@ class Apples:
|
||||||
def __html__(self):
|
def __html__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Allow _missing_, used by enum.Enum.
|
||||||
|
@classmethod
|
||||||
|
def _missing_(cls, value):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def __foo_bar__(): # this is not checked by the [bad-dunder-name] rule
|
def __foo_bar__(): # this is not checked by the [bad-dunder-name] rule
|
||||||
...
|
...
|
||||||
|
|
|
@ -196,5 +196,13 @@ fn is_known_dunder_method(method: &str) -> bool {
|
||||||
| "__trunc__"
|
| "__trunc__"
|
||||||
| "__weakref__"
|
| "__weakref__"
|
||||||
| "__xor__"
|
| "__xor__"
|
||||||
|
// Overridable sunder names from the `Enum` class.
|
||||||
|
// See: https://docs.python.org/3/library/enum.html#supported-sunder-names
|
||||||
|
| "_name_"
|
||||||
|
| "_value_"
|
||||||
|
| "_missing_"
|
||||||
|
| "_ignore_"
|
||||||
|
| "_order_"
|
||||||
|
| "_generate_next_value_"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue