Skip to content

refactor: enable ruff UP (pyupgrade) lint rules#208

Merged
mortenoh merged 1 commit intomasterfrom
refactor/enable-ruff-up-rules
Feb 16, 2026
Merged

refactor: enable ruff UP (pyupgrade) lint rules#208
mortenoh merged 1 commit intomasterfrom
refactor/enable-ruff-up-rules

Conversation

@mortenoh
Copy link
Contributor

@mortenoh mortenoh commented Feb 16, 2026

Summary

  • Enable the UP (pyupgrade) rule group in ruff alongside the existing I (import sorting) rules
  • Fix all ~460 violations across 76 source files in chap_core/
  • Upgrade ruff 0.14.14 -> 0.15.1

Violation breakdown

Rule Count Description
UP045 178 Optional[X] -> X | None
UP006 163 typing.List -> list, typing.Dict -> dict
UP035 52 deprecated imports (e.g. typing.Iterable -> collections.abc.Iterable)
UP015 13 redundant open() modes
UP007 11 Union[X, Y] -> X | Y
UP046 10 PEP 695 generic class syntax
UP042 2 (str, Enum) -> StrEnum
UP031 5 printf-style formatting -> f-strings
UP037 4 remove quotes from annotations
UP017 2 datetime.timezone.utc -> datetime.UTC
UP040 2 PEP 695 type alias syntax
UP028 1 yield in for loop -> yield from

Test plan

  • uv run ruff check chap_core/ passes with zero violations
  • make lint passes (ruff check + ruff format + mypy -- mypy errors are pre-existing)
  • make test passes (538 passed, 118 skipped)

Add "UP" to ruff select rules and fix all 457 violations:
- UP045: Optional[X] -> X | None
- UP006: typing.List -> list, typing.Dict -> dict, etc.
- UP035: deprecated typing imports -> collections.abc equivalents
- UP015: redundant open() modes
- UP007: Union[X, Y] -> X | Y
- UP046: Generic[T] -> PEP 695 type parameter syntax
- UP037: remove quotes from annotations
- UP017: datetime.timezone.utc -> datetime.UTC
- UP040: PEP 695 type alias syntax
- UP028: yield in for loop -> yield from
- UP031: printf-style formatting -> f-strings
@mortenoh mortenoh force-pushed the refactor/enable-ruff-up-rules branch from dba78d0 to 9a980f6 Compare February 16, 2026 12:13
@mortenoh mortenoh merged commit d7c48c3 into master Feb 16, 2026
6 checks passed
@mortenoh mortenoh deleted the refactor/enable-ruff-up-rules branch February 16, 2026 12:52
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.

1 participant

Comments