Repository navigation
[CHORE] Suggest ruff import sorting on changed files - #1516
Conversation
Pyright Type CompletenessView the full Project (full
Other symbols referenced but not exported by
Symbols without documentation:
Patch (exported symbols added or changed by this PR): no exported symbol type-completeness changes detected. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1516 +/- ##
=======================================
Coverage 94.36% 94.36%
=======================================
Files 97 97
Lines 6188 6188
Branches 798 798
=======================================
Hits 5839 5839
Misses 225 225
Partials 124 124
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
given how many files this PR is currently touching, i'm hoping the following comes across as a scope reduction, rather than creep is it possible for a github action to simply warn or recommends fixes for a new ruff rule? if it's possible, i would recommend that we go that route. basically, for future PRs, this action would run on changed files, and recommend fixes. |
|
Yes, it is possible, so I reworked the PR that way: the 130-file reformat is reverted and the Ruff workflow has a step that shows the import-sorting diff for the files a PR changes, without failing the job. The net change is now 2 files (+21 lines), and its first real run is this PR's own Ruff job. |
Fixes #1498.
Following the review, this no longer reformats the repository. It adds the
[tool.ruff.lint.isort]settings proposed in the issue, unchanged, topyproject.toml, and a step to the Ruff workflow that suggests import fixes for the files a pull request changes.The step runs only on pull requests, takes the Python files and notebooks changed against the base branch, and runs
ruff check --select I --diff --exit-zeroon them, so the log shows the diff that would sort their imports and the job never fails because of it. TheIrule is not added to the selected rules, soruff checkon the whole repository behaves as before. The Ruff job now checks out withfetch-depth: 0so the base branch is available.Checked locally: on a file with unsorted imports the command prints the diff and exits 0, on a sorted file it prints nothing and exits 0, and the workflow file parses as YAML. The step itself only runs in CI, so this pull request's own Ruff run is the first real test of it; it will find nothing to report here unless a changed file has unsorted imports.