Search I have tried
SLOT002
There are no duplicate issues.
Problem
Ruff says to me:
SLOT002 Subclasses of `collections.namedtuple()` should define `__slots__`
But I inherit from namedtuple and Enum at the same time.
Reproducible example
from collections import namedtuple
from enum import Enum
class Foobar(namedtuple("conventional_sign", "name description"), Enum):
__slots__ = ()
FOO = 1, "Hello, World!"
BAR = 2, "Some text here"
@classmethod
def item_description(cls, conventional_sign: int) -> str:
for value in cls.__members__.values():
if conventional_sign == value[0]:
return value[1]
raise ValueError(f"{conventional_sign} not in {cls.__members__.values()}")
Correct (expected) behavior
Look on all parent classes before recommending to add __slots__.
For example, Enum has no __slots__ (python/cpython#90290).
Versions