Skip to content

chore: use StrEnum for the four enums that subclass str - #4180

Merged
Fokko merged 1 commit into
apache:mainfrom
oresttokovenko:pyupgrade-311
Oct 29, 2026
Merged

Fokko merged 1 commit into
apache:mainfrom
oresttokovenko:pyupgrade-311

Conversation

@oresttokovenko

@oresttokovenko oresttokovenko commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What

Python 3.11 introduce the native StrEnum class, so I used Ruff's UP042 to convert the four existing enums that subclass str, so the SnapshotRefType.__str__ method becomes redundant (in one of them), the rest are simple swaps

Why

Modernizing and simplifying the codebase

Tests

Tested with make lint and the unit suites

Python 3.11 added enum.StrEnum, and ruff's UP042 (preview) asks for it.
HttpMethod, FileFormat, IsolationLevel and SnapshotRefType all qualify.

SnapshotRefType.__str__ goes away because StrEnum already returns the value.
For the other three, str() and f-strings now render the value instead of the
class-qualified name, so FileFormat.AVRO prints as AVRO where it used to print
as FileFormat.AVRO. repr() keeps the class name, and the values, equality,
hashing and JSON output are unchanged.

No code or test in the repository relied on the old strings.
@Fokko
Fokko enabled auto-merge October 29, 2026 15:36
@Fokko
Fokko added this pull request to the merge queue Oct 29, 2026
Merged via the queue into apache:main with commit 06a529d Oct 29, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants