Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create rule to prefer class based syntax over functional syntax for Enums #12417

Open
mezuzza opened this issue Jul 20, 2024 · 0 comments · May be fixed by #15625
Open

Create rule to prefer class based syntax over functional syntax for Enums #12417

mezuzza opened this issue Jul 20, 2024 · 0 comments · May be fixed by #15625
Labels
rule Implementing or modifying a lint rule

Comments

@mezuzza
Copy link

mezuzza commented Jul 20, 2024

There are a number of cases where you have a choice between class based syntax and functional syntax. The specific case I'm considering is Enum - though I do vaguely recall that there are other cases.

For example, you defined an enum using either of these methods:

class Color(Enum):
    RED = auto()
    YELLOW = auto()
    GREEN = auto()
Color = Enum(
    "Color",
    [
        "RED",
        "YELLOW",
        "GREEN",
    ],
)

What you prefer is a matter of taste (though honestly, if you prefer functional style, you're a little crazy) - however, I'd like to make sure we prefer the former throughout our codebase at work. This lint could obviously warn in either direction.

I'm a little surprised this suggestion didn't exist before tbh, so feel free to point me to the old ticket if it exists. I did search for "enums" and "functional" to try to find this issue, but I couldn't find it (I also tried a few others queries, but you get the idea).

@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Jul 20, 2024
@InSyncWithFoo InSyncWithFoo linked a pull request Jan 21, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants