Enable ruff I (import sorting) rule#1348
Merged
Merged
Conversation
Adds ``I`` to ``[tool.ruff.lint]`` select alongside ``UP``, so ruff also covers import order. The ``ruff-check`` pre-commit hook now runs with ``--fix --exit-non-zero-on-fix --show-fixes`` so import-order fixes apply on commit and abort the commit when something changed. Sorted imports in six files to match the new rule. AGENTS.md updated to mention the additional lint group.
The CHANGES/1348.contrib.rst fragment references ruff's pyupgrade group; without this entry the towncrier-fragments preview that the docs build inlines into changes.rst fails the spell check.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1348 +/- ##
=======================================
Coverage 99.86% 99.86%
=======================================
Files 28 28
Lines 3627 3627
Branches 265 265
=======================================
Hits 3622 3622
Misses 3 3
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
What do these changes do?
Enables the
I(import sorting) rule in[tool.ruff.lint]alongside the existing
UP(pyupgrade) group, and updates theruff-checkpre-commit hook to run with--fix --exit-non-zero-on-fix --show-fixesso import-order fixesapply on commit (and abort the commit when something changed). This
follows the same pattern as yarl PR
#1698: one tool, one
rev, for both formatting and import sorting.
Sorted imports in six files where
ruff check --select I --fixfound drift (
tests/conftest.py,tests/isolated/multidict_pop.py,tests/test_circular_imports.py,tests/test_mutable_multidict.py,benchmarks/benchmark.py,benchmarks/istr.py).AGENTS.mdupdated to reflect the additional lint group, so the"only the
UPgroup enabled" guidance no longer contradicts theconfig.
Are there changes in behavior for the user?
No, contributor tooling only.
Is it a substantial burden for the maintainers to support this?
No. One additional lint rule sharing the existing
[tool.ruff]config; no new pre-commit hooks were added.
Related issue number
N/A; mirrors the approach taken in yarl #1698.
Checklist
AGENTS.mdupdated)CONTRIBUTORS.txt: N/A (no such file in this repo)CHANGES/folder (CHANGES/1348.contrib.rst)Agent run details (optional, for reviewers)
Drafted with Claude Code (Opus 4.7); reviewed by @bdraco.
Verified: