Skip to content

refactor: replace black, isort and pylint with ruff - #273

Merged
hf-krechan merged 3 commits into
mainfrom
migrate-to-ruff
Aug 3, 2026
Merged

refactor: replace black, isort and pylint with ruff#273
hf-krechan merged 3 commits into
mainfrom
migrate-to-ruff

Conversation

@hf-krechan

Copy link
Copy Markdown
Contributor

Summary

  • Replaces black, isort, and pylint with ruff across dev dependencies, config, pre-commit, and CI.
  • pyproject.toml: merged the formatting (black/isort) and linting (pylint) dependency groups into one linting group holding just ruff==0.16.0; translated [tool.black]/[tool.isort]/[tool.pylint."MESSAGES CONTROL"] into [tool.ruff]/[tool.ruff.lint] (baseline select E, W, F, I, UP, B, N, PL, RUF; the usual PLR09xx ignores; extend-exclude = ["*.md"] since ruff format also reformats fenced code blocks in docs, unlike black).
  • Deleted tests/.pylintrc and .pylintrc_autogen_code - their disables either have no ruff equivalent (R0801 duplicate-code, R0903 too-few-public-methods, W0621 redefined-outer-name, docstring rules we don't select) or were translated into a per-file-ignores entry for src/borm/models/** (F401, E501) mirroring the autogenerated-code rcfile.
  • .pre-commit-config.yaml: swapped the psf/black + pycqa/isort hooks for astral-sh/ruff-pre-commit v0.16.0 (ruff-check --fix, ruff-format).
  • CI: pythonlint.yml and the release workflow python-publish.yml (only runs on release: events, so it wouldn't have failed this PR - it had its own separate pylint invocation) now run ruff check src/borm tests, matching pylint's old combined scope exactly. formatting.yml's tool: ["black", "isort"] matrix is preserved via matrix.include, pairing each value with a real ruff command, plus an explicit job name: so the two required status checks (black (3.11, ubuntu-latest, black) / black (3.11, ubuntu-latest, isort), confirmed via the branch protection API) keep reporting under their old names.
  • Fixed a real regression risk found along the way: both alembic.ini files (postgresql_db, mysql_db) had a post_write_hooks entry shelling out to black via the console_scripts runner to format autogenerated migration files. Since black is being removed entirely, the next alembic revision --autogenerate would have broken. Switched both to an exec-type hook calling ruff format (ruff has no console_scripts entry point, unlike black) - verified with a smoke test against a dummy revision file.
  • README: badge alt-text referencing "Black" updated to "Formatting".
  • Left the now-dead # pylint: disable=... comments in place (ruff never read them, and most have no ruff equivalent) rather than stripping them as a separate cosmetic cleanup.

Test plan

  • ruff check src/borm tests (pylint's old scope) - clean
  • ruff format --check . (black/isort's old scope) - clean
  • ruff check --select I . (isort-equivalent) - clean
  • uv.lock diff reviewed - only removes black/isort/pylint transitive deps, adds ruff, no unrelated churn
  • Migration files and workflow YAML re-validated for syntax after ruff's autofixes
  • alembic exec post-write hook smoke-tested against a dummy revision file
  • Full mypy --strict / pytest intentionally not run locally (resource-constrained machine) - relying on CI

Tracking issue: #272

🤖 Generated with Claude Code

Merges the formatting and linting dependency groups into one ruff group,
translates the old [tool.black]/[tool.isort]/[tool.pylint] config into
[tool.ruff], rewrites .pre-commit-config.yaml and the CI lint/formatting
jobs (preserving required status check names), and switches the alembic
post_write_hooks from black to ruff format so migration autogeneration
keeps working now that black is gone.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the repository’s Python formatting/linting toolchain from Black/isort/pylint to Ruff, updating developer workflows (pre-commit), configuration, and CI so the same checks keep running under the new tool.

Changes:

  • Replace Black/isort/pylint dependency groups and configs with ruff==0.16.0 and [tool.ruff] / [tool.ruff.lint] in pyproject.toml.
  • Update pre-commit and CI workflows to run ruff check / ruff format instead of Black/isort/pylint (including preserving legacy required-check job names for branch protection).
  • Update Alembic post-write hooks to format generated migrations via ruff format instead of black.

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated no comments.

Show a summary per file
File Description
uv.lock Removes direct dev dependency entries for black/isort/pylint and adds ruff; updates resolved lock contents accordingly.
tests/integrationtests/test_main.py Applies import reordering consistent with new lint/format tooling.
tests/integrationtests/conftest.py Updates Generator import to collections.abc style (Python 3.11+).
tests/.pylintrc Removes pylint test configuration (pylint no longer used).
src/borm/db/postgresql_db/migrations/versions/9f7a0a61d21e_init.py Applies typing modernizations consistent with Ruff/UP rules.
src/borm/db/postgresql_db/auxiliary.py Replaces IOError with OSError for env-loading failure case.
src/borm/db/postgresql_db/alembic.ini Switches Alembic post-write formatting hook from black to ruff format via exec hook.
src/borm/db/mysql_db/migrations/versions/d73a00baaa17_init.py Applies typing modernizations consistent with Ruff/UP rules.
src/borm/db/mysql_db/auxiliary.py Replaces IOError with OSError for env-loading failure case.
src/borm/db/mysql_db/alembic.ini Switches Alembic post-write formatting hook from black to ruff format via exec hook.
src/borm/db/base_class.py Minor formatting-only change.
README.md Updates badge alt-text from “Black” to “Formatting”.
pyproject.toml Replaces black/isort/pylint config and dependency groups with Ruff configuration and a unified linting group.
.pylintrc_autogen_code Removes pylint configuration for autogenerated code (pylint no longer used).
.pre-commit-config.yaml Replaces Black/isort hooks with Ruff check/format hooks.
.github/workflows/pythonlint.yml Updates CI lint step to run ruff check instead of pylint.
.github/workflows/python-publish.yml Updates release workflow lint step to run ruff check instead of pylint.
.github/workflows/formatting.yml Keeps legacy required-check naming while mapping “black/isort” matrix entries to Ruff commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

hf-krechan and others added 2 commits July 31, 2026 15:02
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… across CI jobs

The linting job generates src/borm/models before running ruff check, so it
resolves "borm.models" as first-party. The isort-named job in
formatting.yml never generates it, so ruff falls back to filesystem-based
detection and treats "borm.models" as third-party instead - producing the
opposite "correct" import order from the same ruff check --select I.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@hf-krechan
hf-krechan merged commit b3fd1e7 into main Aug 3, 2026
15 checks passed
@hf-krechan
hf-krechan deleted the migrate-to-ruff branch August 3, 2026 07:06
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