Skip to content

fix: declare public exports for strict type checkers and ship py.typed in bundle - #764

Merged
Vincent Biret (baywet) merged 1 commit into
microsoft:mainfrom
HardMax71:fix/declare-public-exports
Oct 5, 2026
Merged

Vincent Biret (baywet) merged 1 commit into
microsoft:mainfrom
HardMax71:fix/declare-public-exports

Conversation

@HardMax71

Copy link
Copy Markdown
Contributor

Overview

First item of the checklist in #722. Under mypy --strict, a name imported into a package's __init__.py without being listed in __all__ doesn't count as exported, so from kiota_abstractions.serialization import Parsable is an error for strict consumers.

This adds __all__ to the four __init__.py files that re-export names, the same way kiota_abstractions.authentication already does:

  • kiota_abstractions.serialization
  • kiota_abstractions.store
  • kiota_http.middleware
  • kiota_http.middleware.options

It also adds the missing py.typed marker to kiota_bundle, so type checkers use the annotations of the installed package.

Related Issue

Part of #722, which stays open for the remaining items.

Notes

There is no change for normal imports. Every class and constant stays importable, also through from ... import *. The only names * no longer pulls in are the submodule names (parsable, retry_handler, ...). Those landed in the package namespace only as a side effect of the relative imports, and kiota_abstractions.authentication already behaves this way.

With mypy 2.3.1, mypy --strict across the eight library packages goes from 297 to 202 errors. The default mypy run used in CI still passes for every package.

Testing Instructions

  • From packages/abstractions: mypy --strict -p kiota_abstractions reports 86 errors on main and 61 on this branch. From packages/http/httpx, kiota_http goes from 163 to 128.
  • yapf -dr, pylint --disable=W and pytest pass for abstractions, http and bundle, and isort --check-only passes on the changed files.
  • uv build --wheel in packages/bundle now produces a wheel that contains kiota_bundle/py.typed.

…d in bundle

Add __all__ to the kiota_abstractions.serialization, kiota_abstractions.store, kiota_http.middleware and kiota_http.middleware.options packages, matching kiota_abstractions.authentication, and add the missing py.typed marker to kiota_bundle. Part of microsoft#722.
@sonarqubecloud

sonarqubecloud Bot commented Oct 5, 2026

Copy link
Copy Markdown

@baywet
Vincent Biret (baywet) requested a balanced review from Copilot October 5, 2026 16:19

Copilot AI 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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: None

What changed in this PR

Adds explicit public exports for strict type checkers by defining __all__ in key package __init__.py files, aligning behavior with mypy --strict expectations while keeping normal imports unchanged.

Changes:

  • Define __all__ in kiota_http.middleware and kiota_http.middleware.options to formalize re-exported symbols.
  • Define __all__ in kiota_abstractions.serialization and kiota_abstractions.store to make re-exports visible to strict type checkers.
File Description
packages/​http/​httpx/​kiota_http/​middleware/​options/​__init__.py Adds __all__ for re-exported middleware option classes.
packages/​http/​httpx/​kiota_http/​middleware/​__init__.py Adds __all__ for re-exported middleware handlers/types/constants.
packages/​abstractions/​kiota_abstractions/​store/​__init__.py Adds __all__ for store/backing-store public API symbols.
packages/​abstractions/​kiota_abstractions/​serialization/​__init__.py Adds __all__ for serialization public API symbols.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

Each export list exactly matches its imported public names, and the typing marker is correctly placed.

Review effort: Balanced
Findings: None

@baywet
Vincent Biret (baywet) merged commit cf69dc3 into microsoft:main Oct 5, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done ✔️

Development

Successfully merging this pull request may close these issues.

3 participants