Skip to content

Check import order in CI and sort the files that had drifted - #489

Open
jmchilton wants to merge 2 commits into
masterfrom
isort-import-order
Open

Check import order in CI and sort the files that had drifted#489
jmchilton wants to merge 2 commits into
masterfrom
isort-import-order

Conversation

@jmchilton

Copy link
Copy Markdown
Member

This PR description was drafted and posted by Claude (AI assistant) on jmchilton's behalf.

Summary

.isort.cfg and the make format target have configured isort in this repo all along — the settings are nearly identical to Galaxy's (profile=black, force_alphabetical_sort_within_sections, reverse_relative, force_grid_wrap=2; only line_length and the skip paths differ). Nothing ever ran it in CI, so 71 files had drifted out of order.

Two commits, and the second one is the boring one:

  • Check import order in CI — the part worth reviewing. A format tox env running isort --check --diff ., plus a CI leg.
  • Sort imports with isort — a mechanical isort . pass. No behavior change.

This came up because lib/galaxy/jobs/runners/htcondor.py failed Galaxy's isort check on galaxyproject/galaxy#23326, in an import block copied over from pulsar/managers/queued_htcondor.py. Galaxy caught it; Pulsar could not.

Notes for review

Why the format env runs on 3.14 only. The lint job matrix covers 3.7 and 3.14. isort dropped 3.7 support after 5.11, so the two legs would resolve different isort versions and could disagree about the same file. A single 3.14 leg avoids that; this also mirrors how Galaxy keeps format separate from lint.

Why it checks . rather than pulsar test. That matches what make format rewrites, so tools/ and docs/ stay sorted too and the check never disagrees with the fixer.

Dead config removed. setup.cfg carried:

import-order-style = smarkets
application-import-names = pulsar,harness,recorder

Those configure flake8-import-order, which is not in the lint deps, so they have never had any effect. They also describe a different convention from the isort profile actually in use — smarkets wants import X before from X import, which black-profile isort does not enforce. If anyone installed the plugin the two would fight, so they are better gone than latent.

Blast radius

isort --check . inspects the whole tree, so once this lands, open PRs branched from before it will fail the new check until they rebase. Worth timing accordingly.

Validation

  • tox -e format passes on the sorted tree; deliberately unsorting one import block makes it exit 1, so the check demonstrably catches drift rather than just passing.
  • tox -e test-unit equivalent: 241 passed, 1 failed — wsgi_app_test.py::test_standard_requests, which fails identically on unmodified master.
  • flake8 and mypy clean (188 source files).

jmchilton and others added 2 commits August 19, 2026 15:16
.isort.cfg and `make format` have configured isort all along, but nothing ran
it: the lint env installs flake8 alone, so 71 files had drifted out of order.
Add a format env that runs `isort --check --diff .`, matching what `make format`
rewrites, and give it a CI leg.

It runs on 3.14 only. The lint job also covers 3.7, and isort dropped 3.7 after
5.11, so the two legs would resolve different versions and could disagree.

Drop the import-order-style and application-import-names settings from
setup.cfg. They configure flake8-import-order, which is not among the lint deps,
and smarkets style disagrees with the isort profile that is actually in use.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Mechanical `isort .` pass over the files that had drifted. No behavior change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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