Skip to content

ci: type-check a consumer of the built wheels with mypy --strict - #820

Open
Max Azatian (HardMax71) wants to merge 2 commits into
microsoft:mainfrom
HardMax71:ci/strict-typing-consumer-check
Open

Max Azatian (HardMax71) wants to merge 2 commits into
microsoft:mainfrom
HardMax71:ci/strict-typing-consumer-check

Conversation

@HardMax71

Copy link
Copy Markdown
Contributor

Overview

Last item in #722. A new CI job builds the eight wheels with python -m build, as the release pipeline does, installs them and runs mypy --strict on tests/consumer/consumer.py. That file uses the public API of every package and pins representative return types with assert_type. It runs on the same Python matrix as the other jobs and feeds check-python-version-matrix.

Related Issue

Closes #722.

Demo

Not needed for this change.

Notes

The job checks the installed wheels, not the source tree, so it sees what a consumer sees: a missing py.typed, a name left out of __all__, or a return type that turns into Any. Against wheels built from 37492f7, where #722 started, it reports 15 errors, the issue's RetryHandlerOption().get_key() example among them. On main it reports none.

Testing Instructions

  • Build and install the wheels in a fresh environment: for p in abstractions authentication/azure http/httpx serialization/form serialization/json serialization/text serialization/multipart bundle; do python -m build --wheel --outdir dist "packages/$p"; done; pip install dist/*.whl -r tests/consumer/requirements-dev.txt
  • cd tests/consumer && mypy consumer.py passes on Python 3.10, 3.12 and 3.13.
  • Deleting kiota_bundle/py.typed from the installed package makes it fail with import-untyped.

A new job builds the eight wheels with python -m build, as the release pipeline does, installs them and runs mypy --strict on tests/consumer/consumer.py. That file uses the public API of every package and pins representative return types with assert_type, so the job fails when a package loses py.typed, an export or a return type. Against wheels built from 37492f7, where microsoft#722 started, it reports 15 errors.
@HardMax71
Max Azatian (HardMax71) requested a review from a team as a code owner October 20, 2026 20:08
Copilot AI balanced review requested due to automatic review settings October 20, 2026 20:08

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 was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment thread .github/workflows/build.yml Fixed
Comment thread .github/workflows/build.yml Fixed
Comment thread .github/workflows/build.yml Fixed
Comment thread .github/workflows/build.yml Fixed
pip install --only-binary :all: for both installs in type-check-installed-wheels, so no dependency runs a setup script. Every dependency has a wheel on Python 3.10 to 3.15.
Copilot AI balanced review requested due to automatic review settings October 20, 2026 20: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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Comment thread .github/workflows/build.yml
Comment thread .github/workflows/build.yml
@HardMax71

Copy link
Copy Markdown
Contributor Author

Vincent Biret (@baywet) the two remaining Sonar findings (locked versions) are the same rule that is open on main for the existing build and validation jobs (build.yml L51 and L91). Could you mark them as safe, or should this job pin with hashes?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Complete library typing and enforce mypy strict in CI

3 participants