Skip to content

Remove Any from parse.py#2516

Merged
DanielNoord merged 1 commit intoPyCQA:mainfrom
DanielNoord:type-imports
Apr 15, 2026
Merged

Remove Any from parse.py#2516
DanielNoord merged 1 commit intoPyCQA:mainfrom
DanielNoord:type-imports

Conversation

@DanielNoord
Copy link
Copy Markdown
Member

Preparation for #2503 to make that a bit easier to follow.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.15%. Comparing base (807e851) to head (b8002af).
⚠️ Report is 2 commits behind head on main.

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DanielNoord DanielNoord enabled auto-merge April 15, 2026 20:15
@DanielNoord DanielNoord added this pull request to the merge queue Apr 15, 2026
Merged via the queue into PyCQA:main with commit 22adde2 Apr 15, 2026
28 checks passed
@DanielNoord DanielNoord deleted the type-imports branch April 15, 2026 20:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 via TypedDict/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.

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.

2 participants