Skip to content

feat: allow local preservation of redundant aliases - #2706

Closed
anshurajbisoyi98-ctrl wants to merge 6 commits into
PyCQA:mainfrom
anshurajbisoyi98-ctrl:feature-2189-local-alias-preservation
Closed

anshurajbisoyi98-ctrl wants to merge 6 commits into
PyCQA:mainfrom
anshurajbisoyi98-ctrl:feature-2189-local-alias-preservation

Conversation

@anshurajbisoyi98-ctrl

@anshurajbisoyi98-ctrl anshurajbisoyi98-ctrl commented Oct 3, 2026 •

Copy link
Copy Markdown

Fixes #2189.
Adds # isort: remove-redundant-aliases-off and

isort: remove-redundant-aliases-on action comments so selected

imports can retain explicit re-export aliases while still being sorted.
Each directive creates a sorting boundary, including with float_to_top.
The on directive restores the global setting. Directives inside strings
or sections disabled with # isort: off are ignored.
Regression tests cover ordinary and relative imports, LF and CRLF line
endings, repeated sorting, and restoring the global setting. The action
comment documentation describes the new behavior.
The directive names use redundant, matching the existing remove_redundant_aliases setting rather than the typo in the issue’s example.
Validation:

  • Full unit suite: 687 passed, 1 skipped.
  • Ruff lint and formatting checks passed.
  • Mypy passed for 86 source files.
  • All 12 new preservation regression cases failed before the fix and
    passed afterward.
    Ruff reported two existing invalid noqa warnings in unchanged files.
    Other Python versions, platforms, and integration tests were not tested.
    AI assistance: Codex assisted with implementation, regression tests,
    verification and documentation.

Signed-off-by: Anshu Raj Bisoyi <anshurajbisoyi98@gmail.com>
Signed-off-by: Anshu Raj Bisoyi <anshurajbisoyi98@gmail.com>
Signed-off-by: Anshu Raj Bisoyi <anshurajbisoyi98@gmail.com>
Signed-off-by: Anshu Raj Bisoyi <anshurajbisoyi98@gmail.com>
Signed-off-by: Anshu Raj Bisoyi <anshurajbisoyi98@gmail.com>
Signed-off-by: Anshu Raj Bisoyi <anshurajbisoyi98@gmail.com>
@DanielNoord

Copy link
Copy Markdown
Member

See linked issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possibility to locally turn off remove_redundent_aliases

2 participants