Skip to content

Should SomeStrEnum(str, Enum) require SLOT000? #5748

@charliermarsh

Description

@charliermarsh

Discussed in #5747

Originally posted by jamesbraza July 13, 2023
Please see the below file with Python 3.10.10:

from enum import Enum

class SomeStrEnum(str, Enum):
    KEY = "value"

Running ruff==0.0.278 on this:

> ruff --isolated --select="SLOT" a.py
a.py:3:7: SLOT000 Subclasses of `str` should define `__slots__`
Found 1 error.

Running flake8-slots==0.1.5 with flake8==4.0.1 on this, there's no error:

> flake8 a.py

Fwiw, Python 3.11's built-in enum.StrEnum doesn't seem to define __slots__.

I am not sure if there should or should not be SLOT000 for this. Looks like @qdegraaf added SLOT rule in ruff==0.0.273, so notifying him.

I am thinking either:

  • This is a false positive of SLOT000
  • Or should the built-in StrEnum define __slots__?

Metadata

Metadata

Assignees

Labels

acceptedReady for implementationbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions