fix: sort_reexports should respect isort: skip comment (#2569)#2570
Open
muhamedfazalps wants to merge 2 commits into
Open
fix: sort_reexports should respect isort: skip comment (#2569)#2570muhamedfazalps wants to merge 2 commits into
muhamedfazalps wants to merge 2 commits into
Conversation
staticdev
requested changes
Jun 29, 2026
| code_sorting_indent = line[: -len(line.lstrip())] | ||
| not_imports = True | ||
| elif config.sort_reexports and stripped_line.startswith("__all__"): | ||
| elif config.sort_reexports and stripped_line.startswith("__all__") and "isort: skip" not in stripped_line: |
Collaborator
There was a problem hiding this comment.
Could you please add a test to reproduce the issue?
|
Thanks for working on this! I tested this PR on my original reproduction in #2569 and it no longer errors! |
When sort_reexports is enabled, __all__ assignments with # isort: skip were still being sorted. Added check for isort: skip comment before processing re-exports. Signed-off-by: Muhamed Fazal PS <fazaleee123cr7@gmail.com>
790b63f to
ef581df
Compare
Collaborator
|
@BD103 I will merge it as soon as we have test coverage. |
Add 3 tests covering: - Non-literal __all__ with isort: skip (the reported issue) - Literal __all__ with isort: skip - Literal __all__ without skip still sorts All tests pass. Maintainer requested test coverage before merge.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2570 +/- ##
==========================================
+ Coverage 99.16% 99.32% +0.16%
==========================================
Files 41 41
Lines 3101 3111 +10
Branches 671 674 +3
==========================================
+ Hits 3075 3090 +15
+ Misses 14 11 -3
+ Partials 12 10 -2 🚀 New features to boost your workflow:
|
DanielNoord
approved these changes
Jul 11, 2026
DanielNoord
left a comment
Member
There was a problem hiding this comment.
Could you fix the failing CI check? Deepsource can be ignored. Otherwise this LGTM!
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.
Fixes #2569
When sort_reexports is enabled, all assignments with # isort: skip comments were still being sorted because the skip comment was not checked before processing.