Skip to content

Comments

[pyupgrade] Functional enums (UP048)#15625

Closed
InSyncWithFoo wants to merge 3 commits intoastral-sh:mainfrom
InSyncWithFoo:UP048
Closed

[pyupgrade] Functional enums (UP048)#15625
InSyncWithFoo wants to merge 3 commits intoastral-sh:mainfrom
InSyncWithFoo:UP048

Conversation

@InSyncWithFoo
Copy link
Contributor

Summary

Resolves #12417.

Test Plan

cargo nextest run and cargo insta test.

@github-actions
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.

@MichaReiser MichaReiser added the needs-decision Awaiting a decision from a maintainer label Jan 21, 2025
@InSyncWithFoo InSyncWithFoo deleted the UP048 branch March 11, 2025 15:53
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