Skip to content

Excluding Enum classes from the rule WPS115 misses StrEnum #3381

@NikitaSemenovAiforia

Description

@NikitaSemenovAiforia

What's wrong

1.1.0 release fixes WPS115 with Enum but misses StrEnum base.

The PR and related commit are a bit old and misses the new Python Enum subclasses introduced in 3.11 version.

Here _ENUM_NAMES included not all Enum variants.

How it should be

_ENUM_NAMES should include all Enum subclasses.

WPS115 should act with StrEnum just like with regular enum.

ReprEnum probably has the same bug, but I haven't checked that. It was released in 3.11 alongside StrEnum. And I'm not sure about IntEnum, Flag, IntFlag. Should be tested as well.

But it's not that easy to extend _ENUM_NAMES with new types. Cause basic enums could be used with primiteves to subclassing. And used in this logic. So we need two lists of Enum types: one with simple Enum, one with extended to StrEnum, ReprEnum. And one final.

Flake8 version and plugins

pip information

OS information

Metadata

Metadata

Assignees

No one assigned

    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