Allow sunder names from enum.Enum (#7987)

Closes https://github.com/astral-sh/ruff/issues/7971.
This commit is contained in:
Charlie Marsh 2023-10-16 14:11:14 -04:00 committed by GitHub
parent 1fabaca5de
commit 134def0119
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -63,6 +63,11 @@ class Apples:
def __html__(self):
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
...

View file

@ -196,5 +196,13 @@ fn is_known_dunder_method(method: &str) -> bool {
| "__trunc__"
| "__weakref__"
| "__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_"
)
}