Skip to content

refactor(sdk): enable ruff isort and sort imports tree-wide - #145

Open
quanghexa94 wants to merge 2 commits into
mainfrom
lhq/refactor/enforce-import-sorting
Open

refactor(sdk): enable ruff isort and sort imports tree-wide#145
quanghexa94 wants to merge 2 commits into
mainfrom
lhq/refactor/enforce-import-sorting

Conversation

@quanghexa94

Copy link
Copy Markdown
Collaborator

Enable ruff's import-sorting (isort, rule I) for the Hexgate SDK and sort every import block in the tree so the ordering is enforced going forward. Pure chore, SDK only (hexgate + tests): no runtime behaviour changes, no new dependency, no platform change. This is a standalone PR off main and does not depend on any in-flight agent-enforcement work.

Design

extend-select = ["I"] is added under a new [tool.ruff.lint] in the root pyproject.toml. extend-select (not select) is deliberate: the repo had no [tool.ruff] section, so ruff was running its default rule set (E4/E7/E9, F). Using select would have silently dropped those defaults; extend-select layers isort on top and keeps them. The rest of the diff is entirely ruff check --fix output, reordering existing import statements. No imports were added or removed, only sorted and grouped (stdlib / third-party / first-party).

Important files

File What to look at
pyproject.toml the new [tool.ruff.lint] with extend-select = ["I"]; confirm it does not clobber the default E/F rules
hexgate/**, tests/** mechanical import reorders only; no logic changes

Test plan

Ran from the SDK worktree with the project's env:

  • ruff check hexgate tests after the fix: All checks passed! (before the fix it reported 63 errors, all rule I, all auto-fixed).
  • ruff format --check hexgate tests: 274 files already formatted (the reorders did not disturb formatting).
  • Full unit suite python -m pytest tests/ -q: 2075 passed, 6 skipped, 20 deselected in ~19s, zero errors. This is the check that matters for an import reorder, a bad reorder would surface as an ImportError at collection time (for example a circular import in an __init__.py). Collection was clean and no module needed a # noqa: I001 guard.

A reviewer can catch a regression by re-running the three commands above; ruff check now fails CI on any unsorted import.

Try it

ruff check hexgate tests
ruff format --check hexgate tests
python -m pytest tests/ -q

Notes

  • Scope is the SDK only. platform/api is a separate uv project with its own pyproject.toml and ruff config; enabling isort there is a sensible follow-up in a separate PR and is intentionally left out here.
  • No behaviour change and nothing to roll back beyond reverting the commit.

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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