refactor(sdk): enable ruff isort and sort imports tree-wide - #145
Open
quanghexa94 wants to merge 2 commits into
Open
refactor(sdk): enable ruff isort and sort imports tree-wide#145quanghexa94 wants to merge 2 commits into
quanghexa94 wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
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 offmainand does not depend on any in-flight agent-enforcement work.Design
extend-select = ["I"]is added under a new[tool.ruff.lint]in the rootpyproject.toml.extend-select(notselect) is deliberate: the repo had no[tool.ruff]section, so ruff was running its default rule set (E4/E7/E9, F). Usingselectwould have silently dropped those defaults;extend-selectlayers isort on top and keeps them. The rest of the diff is entirelyruff check --fixoutput, reordering existing import statements. No imports were added or removed, only sorted and grouped (stdlib / third-party / first-party).Important files
pyproject.toml[tool.ruff.lint]withextend-select = ["I"]; confirm it does not clobber the default E/F ruleshexgate/**,tests/**Test plan
Ran from the SDK worktree with the project's env:
ruff check hexgate testsafter 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).python -m pytest tests/ -q:2075 passed, 6 skipped, 20 deselectedin ~19s, zero errors. This is the check that matters for an import reorder, a bad reorder would surface as anImportErrorat collection time (for example a circular import in an__init__.py). Collection was clean and no module needed a# noqa: I001guard.A reviewer can catch a regression by re-running the three commands above;
ruff checknow fails CI on any unsorted import.Try it
Notes
platform/apiis a separateuvproject with its ownpyproject.tomland ruff config; enabling isort there is a sensible follow-up in a separate PR and is intentionally left out here.