Skip to content

Allow str + Enum for WPS600 Forbid subclassing lowercase builtins. #2506

@gotofritz

Description

@gotofritz

Rule request

"WPS600 Forbid subclassing lowercase builtins" should allow the following

class PizzaToppings(str, Enum):
    MARGHERITA = "MARGHERITA"
    MARINARA = "MARINARA"

Thesis

Enums are a bit akwkard in Python. The class PizzaToppings(str, Enum):... construct allows to create what is basically a string equivalent of IntEnum, so that one can do

if current_topping == PizzaToppings.MARINARA:
    ...

Reasoning

It seems beneficial, farily widely used, and has no negative side effects I can think of. No reason to ban it.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions