Skip to content

Make the code more strictly typed without changing the type checker#1030

Merged
Kludex merged 2 commits into
mainfrom
strict-type-annotations
Jun 11, 2026
Merged

Make the code more strictly typed without changing the type checker#1030
Kludex merged 2 commits into
mainfrom
strict-type-annotations

Conversation

@Kludex

@Kludex Kludex commented Jun 11, 2026

Copy link
Copy Markdown
Member

Cleans up typing across httpx2 and httpcore2 so the strict type checker and linter pass without inline workarounds:

  • Add explicit annotations to empty collections that were previously inferred as list[Any]/dict[Any, Any].
  • Replace inline # type: comments with class- and variable-level annotations.
  • Return collections.abc.Generator from context managers instead of typing.Iterator.
  • Import submodules explicitly (anyio.abc, hyperframe.frame, http.cookiejar).
  • Rename unused loop variables to _-prefixed.

httpcore2 sync changes are made in the _async sources and regenerated via unasync.

AI Disclaimer

This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.

Add explicit type annotations to empty collections, replace inline `# type:` comments with class- and variable-level annotations, return `collections.abc.Generator` from context managers instead of `typing.Iterator`, and import submodules explicitly so the strict type checker and linter pass cleanly.
@github-actions

Copy link
Copy Markdown

Docs preview:

@Kludex Kludex changed the title Annotate inferred-Any collections and use collections.abc generators Satisfy strict type checking and lint without inline workarounds Jun 11, 2026
@codspeed-hq

codspeed-hq Bot commented Jun 11, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 15 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing strict-type-annotations (09e7a73) with main (7efe56f)

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Kludex Kludex changed the title Satisfy strict type checking and lint without inline workarounds Make the code more strictly typed without changing the type checker Jun 11, 2026
@Kludex Kludex mentioned this pull request Jun 11, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 25 files

Re-trigger cubic

@Kludex Kludex enabled auto-merge (squash) June 11, 2026 06:19
@Kludex Kludex merged commit 7dc5242 into main Jun 11, 2026
15 checks passed
@Kludex Kludex deleted the strict-type-annotations branch June 11, 2026 06:22
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.

1 participant