Repository navigation
Remove unused imports before sorting in pydabs-codegen - #7375
Merged
Merged
Conversation
In a single `ruff check --fix`, the unused-import removal (F401) and the import sort (I001) overlap, and ruff defers whichever comes second to the next iteration. Which one runs first depends on the neighbouring statements: a whole-statement deletion swallows the newline, so the fix for the statement right after it waits a round, and by then the sort runs first. A long import sorted while it still carries its unused names gets wrapped with a trailing comma, which survives the trim and is never folded back. Adding one import could therefore rewrap unrelated ones. Run F401 on its own first so wrapping depends only on the final line. The regenerated models collapse the imports in 32 files that were wrapped this way; a second run of the task produces no further changes. Co-authored-by: Isaac <no-reply@databricks.com>
Collaborator
Integration test reportCommit: bd88e4a
Top 3 slowest tests (at least 2 minutes):
|
janniklasrose
enabled auto-merge
November 5, 2026 10:48
Sankalp-Mittal
approved these changes
Nov 5, 2026
Collaborator
Integration test reportCommit: 523290c
15 interesting tests: 8 flaky, 7 FAIL
Top 50 slowest tests (at least 2 minutes):
|
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.
Why
./task pydabs-codegenfixes the generated code with a singleruff check --fix. In that run the unused-import removal (F401) and the import sort (I001) overlap, and ruff defers whichever comes second to the next iteration. Which one runs first depends on the neighbouring statements: a whole-statement deletion swallows its newline, so the fix for the statement right after it waits a round, and by then the sort runs first. A long import sorted while it still carries its unused names is wrapped with a trailing comma. The trim keeps the comma, and isort'ssplit-on-trailing-commaplus the formatter's magic trailing comma then keep it multi-line for good.The output is deterministic for a given input, but not local: adding one import to a package can rewrap unrelated imports in the same file. #7366 shows the effect, with
depends_onimports flipping between one line and multi-line across packages for reasons unrelated to that change.Changes
pydabs-codegenrunsruff check --fix --select F401on its own before the existing full fix and format steps, so wrapping depends only on the final line.Tests
./task lint-python,ruff format --check, the pydabs test suite (530 tests) and pyright pass locally.This pull request and its description were written by Isaac.