Skip to content

[isort] Expand I001 documentation - #29843

Merged
ntBre merged 2 commits into
astral-sh:mainfrom
halcyon-past:expand-i001-docs
Nov 3, 2026
Merged

ntBre merged 2 commits into
astral-sh:mainfrom
halcyon-past:expand-i001-docs

Conversation

@halcyon-past

@halcyon-past halcyon-past commented Oct 30, 2026 •

Copy link
Copy Markdown

Summary

Expands the documentation for unsorted-imports (I001) to explain:

  • The default import categorization sections (future, standard-library, third-party, first-party, local-folder) with a link to the categorization FAQ.
  • How sections are separated by a blank line, straight imports generally placed before from imports, and modules sorted by name.
  • Blank-line requirements after the import block (2 blank lines before top-level function and class definitions, 1 blank line before other statements, 1 blank line in stub files) with a link to lint.isort.lines-after-imports.
  • A representative example including standard library, third-party imports, and a top-level function definition.
  • A link to the full isort settings documentation section.
  • References to PEP 8 and the upstream isort documentation.

Closes #27232.

Test Plan

  • Ran cargo dev generate-docs and uv run scripts/check_docs_formatted.py to confirm all docs snippets are formatted correctly.
  • Ran cargo dev generate-all --mode check to confirm generated schemas/docs consistency.
  • Ran cargo test -p ruff_linter -- rules::isort (all 172 tests passed).
  • Ran CARGO_BUILD_WARNINGS=deny cargo clippy -p ruff_linter (passed with 0 warnings).
  • Ran uv run --only-dev --locked prek run --files crates/ruff_linter/src/rules/isort/rules/organize_imports.rs (all hooks passed).

Co-authored-by: Brent Westbrook brentrwestbrook@gmail.com

@ntBre ntBre added the documentation Improvements or additions to public-facing documentation label Nov 2, 2026

@ntBre ntBre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good to me overall. I just had a few suggestions.

Expands the documentation for `unsorted-imports` (`I001`) to explain the default import sections, section separation, module sorting within sections, and blank line requirements after import blocks before top-level definitions vs. statements. Also adds links to the relevant `isort` settings, the FAQ for import categorization, and external references (PEP 8, isort).

Closes astral-sh#27232.

Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
@halcyon-past

Copy link
Copy Markdown
Author

Thanks for the review @ntBre! I've addressed all your suggestions, formatted the docs examples, and updated the PR. Could you take another look when you get a chance?

@halcyon-past
halcyon-past requested a review from ntBre November 3, 2026 13:03

@ntBre ntBre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I pushed a couple of final wording tweaks, but this looks good to me.

@ntBre
ntBre enabled auto-merge (squash) November 3, 2026 15:27
@ntBre
ntBre merged commit d7f77cc into astral-sh:main Nov 3, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to public-facing documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expand I001 documentation

2 participants