Skip to content

PLW3201 flags _missing_ in Enum subclass #7971

@mal

Description

@mal

Enum in Python has a few supported sunder names. Of them, _missing_ and _generate_next_value_ are explicitly called out as overridable but when doing so they get flagged as misspelled dunder methods.

Looks separate from, but related to #4592.

from enum import StrEnum
class Build(StrEnum):
    @classmethod
    def _missing_(cls, value):
        pass
$ ruff --isolated --preview --select PLW3201 --show-source test.py
test.py:4:9: PLW3201 Bad or misspelled dunder method name `_missing_`. (bad-dunder-name)
  |
2 | class Build(StrEnum):
3 |     @classmethod
4 |     def _missing_(cls, value):
  |         ^^^^^^^^^ PLW3201
5 |         pass
  |

Observed using ruff 0.0.292.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions