Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isort: Support disabling sections with no-sections = true #8657

Merged
merged 3 commits into from
Nov 14, 2023

Conversation

jelmer
Copy link
Contributor

@jelmer jelmer commented Nov 13, 2023

Summary

This adds a no-sections option for isort in the linter, similar to the no_sections option 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.

Copy link
Contributor

github-actions bot commented Nov 13, 2023

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@jelmer jelmer marked this pull request as ready for review November 13, 2023 18:06
Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

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.

@charliermarsh charliermarsh added the isort Related to import sorting label Nov 14, 2023
This is similar to what exists in upstream isort.

Fixes astral-sh#8653
@jelmer jelmer changed the title isort: Support disabling sections with no_sections = false isort: Support disabling sections with no-sections = true Nov 14, 2023
Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

Thanks!

@charliermarsh charliermarsh enabled auto-merge (squash) November 14, 2023 18:10
@charliermarsh charliermarsh merged commit 9d76e4e into astral-sh:main Nov 14, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
isort Related to import sorting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support no_sections option for isort
2 participants