isort: Support disabling sections with no-sections = true#8657
Merged
charliermarsh merged 3 commits intoastral-sh:mainfrom Nov 14, 2023
Merged
isort: Support disabling sections with no-sections = true#8657charliermarsh merged 3 commits intoastral-sh:mainfrom
no-sections = true#8657charliermarsh merged 3 commits intoastral-sh:mainfrom
Conversation
Contributor
|
202516f to
40a1c21
Compare
Member
charliermarsh
left a comment
There was a problem hiding this comment.
Thanks for getting involved! No objection to adding this, and no objection to using the same nomenclature and API as isort. Left a few small questions and comments, but should be able to get this merged relatively quickly.
This is similar to what exists in upstream isort. Fixes astral-sh#8653
40a1c21 to
fa21675
Compare
no_sections = falseno-sections = true
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.
Summary
This adds a
no-sectionsoption for isort in the linter, similar to theno_sectionsoption that exists in upstream isort (https://pycqa.github.io/isort/docs/configuration/options.html#no-sections)This option puts all imports except for
__future__into the same section, and is mostly used by monorepos.I've taken a bit of a leap in assuming that ruff wants to support the exact same option; more than happy to refactor if you'd prefer a different way of setting this up.
Fixes #8653
Test Plan
I've added a test and have run it on a large Python codebase that uses isort with --no-sections. The option is disabled by default.