Skip to content

Sort the test suite's leaf imports and reformat two test bodies - #96

Closed
leaf-agent wants to merge 1 commit into
mainfrom
fix/ci-33186976619
Closed

Sort the test suite's leaf imports and reformat two test bodies#96
leaf-agent wants to merge 1 commit into
mainfrom
fix/ci-33186976619

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

Problem

lint is red on main. ruff check --fix and ruff format both rewrite files under tests/, and the pre-commit action fails on any hook that modifies a file. The failing run reported one autofix; three more commits have landed since, so main now carries 8 I001 import-order errors and 2 unformatted files.

The cause is the recent module splits. leaf.registry, leaf.served_state, leaf.validation.command, and leaf.render_gate are submodule imports, which isort orders after the flat from leaf import … block — but each new import was inserted alphabetically among the flat ones (from leaf.served_state import page between from leaf import schema and from leaf import server). Separately, interact_support.page_state and render_cases_widgets.written_anchors fit within the line width once their call targets were renamed by those same splits.

Solution

Ran ruff@0.16.1 check --fix . and ruff@0.16.1 format . — exactly what the ruff-check and ruff-format pre-commit hooks do. No behavior change: every hunk is an import moved within its own block, or a call rewrapped.

Branched from 47f1c35, not the failing run's ae66e73, so the fix covers all four commits that accumulated the drift rather than just the first.

Testing

$ uvx ruff@0.16.1 check --no-fix .
All checks passed!
$ uvx ruff@0.16.1 format --check .
140 files already formatted

The four rewritten test_interact_* modules pass — 391 passed — confirming the reordered imports still resolve.

Files changed
File Change
tests/interact_support.py leaf.served_state import order; page_state rewrapped
tests/render_cases_layout.py leaf.registry import order
tests/render_cases_widgets.py written_anchors tuple rewrapped
tests/test_interact_contract.py leaf.registry import order (4)
tests/test_interact_product.py leaf.validation.command, leaf.registry import order
tests/test_interact_server.py leaf.registry, leaf.served_state import order (3)
tests/test_interact_session.py leaf.registry, leaf.served_state import order (3)
tests/test_render_controls.py leaf.registry import order
tests/test_render_pages.py leaf.registry import order

Automated fix for failed run

ruff-check's isort rule and ruff-format both rewrite files on main, so the
lint job fails. The submodule imports the recent module splits introduced
(leaf.registry, leaf.served_state, leaf.validation.command) were placed
beside the leaf package's flat imports rather than after them, and two call
sites exceed the line width after the moves.
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

lint failed again on mainrun 33188325531, commit 4ac54f6 ("Refactor registry into owned modules"). Same failure this PR fixes: ruff-check autofixing I001 import order and ruff-format rewriting files under tests/. No new fix needed — this branch is based on 47f1c35, which is ahead of the failing commit, and its lint check is green.

Verification against current main

main at 47f1c35 still carries the drift:

$ uvx ruff@0.16.1 check --no-fix .
Found 8 errors.
[*] 8 fixable with the `--fix` option.
$ uvx ruff@0.16.1 format --check .
2 files would be reformatted, 138 files already formatted

This branch at 901958e is clean under the same pinned version the ruff-check / ruff-format hooks use (.pre-commit-config.yaml, rev: v0.16.1):

$ uvx ruff@0.16.1 check --no-fix .
All checks passed!
$ uvx ruff@0.16.1 format --check .
140 files already formatted

The failing run 4ac54f6 is an ancestor of this branch's merge base, so merging closes it out along with ae66e73.

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Closing as superseded: main already carries this diff, so merging this branch would change nothing.

9a2901d ("Centralize shared browser ownership") re-sorted the same leaf.registry / leaf.served_state / leaf.validation.command imports and rewrapped the same two call sites. git merge-tree origin/main 901958e returns 74d10611…, which is origin/main's own tree — the merge is a literal no-op.

Verified on main at 9a2901d:

$ uvx ruff@0.16.1 check --no-fix .
All checks passed!
$ uvx ruff@0.16.1 format --check .
140 files already formatted

ci's lint job is green there too — run 33193890939.

How this thread ended here

This PR was opened for run 33186976619 and re-cited for 33188325531. The same lint failure recurred once more on 33192065454 (5c5547a), and the next commit to land fixed it directly rather than through this branch.

That is the fourth import-order break to reach main in a day (#89, #90, #94, this one). Each was ruff's I001 on a from leaf.<sub> import … line inserted alphabetically among the flat from leaf import … block during a module split — the drift is a by-product of the splits, not of any one commit.

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