Remove Any from parse.py#2516
Merged
DanielNoord merged 1 commit intoPyCQA:mainfrom Apr 15, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2516 +/- ##
=======================================
Coverage 99.15% 99.15%
=======================================
Files 41 41
Lines 3065 3066 +1
Branches 662 662
=======================================
+ Hits 3039 3040 +1
Misses 14 14
Partials 12 12 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR tightens type information around parsed import structures (removing Any usage in parse.py) as groundwork for the upcoming work on sorting lazy imports.
Changes:
- Refines
parse.py’s internal typing for parsed imports, comments, and sections viaTypedDict/concrete types. - Updates comment handling to allow
None(instead of relying on empty tuples) when wrapping import statements. - Adjusts a couple of call sites and annotations in output generation to align with the more precise types.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
isort/parse.py |
Replaces Any-based structures with TypedDict and concrete types for imports, comments, and sections. |
isort/wrap.py |
Makes comments optional (None) and normalizes to an empty sequence internally. |
isort/output.py |
Updates local annotations and pop() defaults to work with optional comment lists and the refined parsed-import types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Preparation for #2503 to make that a bit easier to follow.