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

[pyupgrade] Functional enums (UP048) #15625

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

InSyncWithFoo
Copy link
Contributor

Summary

Resolves #12417.

Test Plan

cargo nextest run and cargo insta test.

Copy link
Contributor

github-actions bot commented Jan 21, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+3 -0 violations, +0 -0 fixes in 3 projects; 52 projects unchanged)

apache/airflow (+1 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select ALL

+ tests/serialization/test_serde.py:152:9: UP048 [*] Enum declared using functional syntax

python-trio/trio (+1 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview

+ src/trio/_ssl.py:253:1: UP048 [*] Enum declared using functional syntax

pytest-dev/pytest (+1 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview

+ testing/test_compat.py:163:5: UP048 [*] Enum declared using functional syntax

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
UP048 3 3 0 0 0

@MichaReiser MichaReiser added rule Implementing or modifying a lint rule preview Related to preview mode features labels Jan 21, 2025
@MichaReiser
Copy link
Member

MichaReiser commented Jan 21, 2025

I'm not sure UP is a good fit. Using class—or functional-based enums seems more a matter of taste than whether one is considered better (because it was intentionally designed for it) than the other.

I think this is also visible in the ecosystem checks, where the function-based notation is more concise than the class one.

Overall, I think we should hold off with this rule. It seems too opinionated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-decision Awaiting a decision from a maintainer preview Related to preview mode features rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create rule to prefer class based syntax over functional syntax for Enums
2 participants