refactor: replace black, isort and pylint with ruff - #273
Merged
Conversation
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.
6 tasks
There was a problem hiding this comment.
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.0and[tool.ruff]/[tool.ruff.lint]inpyproject.toml. - Update pre-commit and CI workflows to run
ruff check/ruff formatinstead 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 formatinstead ofblack.
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.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pyproject.toml: merged theformatting(black/isort) andlinting(pylint) dependency groups into onelintinggroup holding justruff==0.16.0; translated[tool.black]/[tool.isort]/[tool.pylint."MESSAGES CONTROL"]into[tool.ruff]/[tool.ruff.lint](baseline selectE, W, F, I, UP, B, N, PL, RUF; the usualPLR09xxignores;extend-exclude = ["*.md"]sinceruff formatalso reformats fenced code blocks in docs, unlike black).tests/.pylintrcand.pylintrc_autogen_code- their disables either have no ruff equivalent (R0801duplicate-code,R0903too-few-public-methods,W0621redefined-outer-name, docstring rules we don't select) or were translated into aper-file-ignoresentry forsrc/borm/models/**(F401,E501) mirroring the autogenerated-code rcfile..pre-commit-config.yaml: swapped thepsf/black+pycqa/isorthooks forastral-sh/ruff-pre-commitv0.16.0 (ruff-check --fix,ruff-format).pythonlint.ymland the release workflowpython-publish.yml(only runs onrelease:events, so it wouldn't have failed this PR - it had its own separate pylint invocation) now runruff check src/borm tests, matching pylint's old combined scope exactly.formatting.yml'stool: ["black", "isort"]matrix is preserved viamatrix.include, pairing each value with a real ruff command, plus an explicit jobname: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.alembic.inifiles (postgresql_db, mysql_db) had apost_write_hooksentry shelling out toblackvia theconsole_scriptsrunner to format autogenerated migration files. Since black is being removed entirely, the nextalembic revision --autogeneratewould have broken. Switched both to anexec-type hook callingruff format(ruff has noconsole_scriptsentry point, unlike black) - verified with a smoke test against a dummy revision file.# 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) - cleanruff format --check .(black/isort's old scope) - cleanruff check --select I .(isort-equivalent) - cleanuv.lockdiff reviewed - only removes black/isort/pylint transitive deps, adds ruff, no unrelated churnexecpost-write hook smoke-tested against a dummy revision filemypy --strict/pytestintentionally not run locally (resource-constrained machine) - relying on CITracking issue: #272
🤖 Generated with Claude Code