Skip to content

chore(deps): add ruff linter alongside existing tools#653

Merged
LaikaN57 merged 5 commits intomainfrom
chore/add-ruff-linter
Feb 25, 2026
Merged

chore(deps): add ruff linter alongside existing tools#653
LaikaN57 merged 5 commits intomainfrom
chore/add-ruff-linter

Conversation

@LaikaN57
Copy link
Member

Summary

  • Add ruff 0.15.2 as a parallel linter alongside black and pyflakes (does NOT replace them in CI)
  • New Makefile targets: make ruff, make ruff-fix, make ruff-format
  • Fix all 129 ruff violations across the codebase

Violation breakdown

Category Count Impact
B904 (raise from) 61 Preserves exception chains for debugging
I001 (import sorting) 28 Consistent import ordering
UP031/UP032 (%-formatting → f-strings) 27 Completes remaining items from #651
UP024 (IOError → OSError) 3 Use canonical exception name
UP045 (Optional → X | None) 2 PEP 604 syntax
UP034, UP020, F841 4 Misc cleanup (parens, io.open, unused var)
F401 (unused import) 1 Remove unused import io
I001 (residual) 3 Re-sort after Optional removal

Conflict resolution

  • E501 suppressed in ruff config — black handles line length (marked TODO(ruff-primary))
  • E402, B006, B008, E741, B017 suppressed — intentional patterns
  • ruff format NOT used — black remains the sole formatter
  • All existing CI checks (make lint, make test) pass unchanged

Rule set enabled

E, F, W, I, B, UP, ASYNC, RUF006

Test plan

  • make lint passes (black unchanged)
  • make test — 361 passed, 100% coverage
  • make ruff — 0 violations
  • CI validates

🤖 Generated with Claude Code

LaikaN57 and others added 5 commits February 25, 2026 12:29
Add ruff 0.15.2 as a dev dependency with [tool.ruff] configuration in
pyproject.toml. New Makefile targets: `make ruff`, `make ruff-fix`,
`make ruff-format`. Existing `make lint` and `make test` are unchanged.

Rule set: E, F, W, I, B, UP, ASYNC, RUF006
Suppressed: E501 (black handles line length), E402, B006, B008, E741

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- I001: Sort imports per isort conventions (28 files)
- UP024: IOError → OSError (alias since Python 3.3)
- UP032: .format() → f-strings (3 instances)
- UP034: Remove extraneous parentheses (2 instances)
- UP020: io.open → open (alias since Python 3)
- F841: Remove unused exception variable

Black re-applied after ruff fixes to resolve formatting conflicts
(black takes precedence per conflict resolution policy).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add `from e` to 58 raise statements inside except blocks to preserve
the original exception chain in __cause__. Use `from None` for 3 cases
where the original exception is intentionally suppressed.

This preserves full tracebacks for debugging — previously, re-raised
exceptions lost their original cause.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ions

- UP031: Convert 27 remaining printf-style format strings to f-strings
  (test files and a few production lines missed in #651)
- UP045: Optional[str] → str | None (PEP 604, 2 instances)
- Remove unused `from typing import Optional` import

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- UP032: .format() → f-strings (residual from UP031 conversion)
- I001: Re-sort imports after removing typing.Optional
- F401: Remove unused `import io` (after UP020 converted io.open → open)

Ruff now reports 0 violations. Black and all 361 tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment on lines -297 to +294
r"{0}(([\w]+)[|]([^{1}]+)){1}".format(left_wrapper, right_wrapper), string
rf"{left_wrapper}(([\w]+)[|]([^{right_wrapper}]+)){right_wrapper}", string
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the intention here was to keep the regex readable, hence we used format instead of in-line f-strings.

@LaikaN57 LaikaN57 marked this pull request as ready for review February 25, 2026 22:05
@LaikaN57 LaikaN57 merged commit 7584aa5 into main Feb 25, 2026
4 checks passed
@LaikaN57 LaikaN57 deleted the chore/add-ruff-linter branch February 25, 2026 22:05
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