Skip to content

Mark the Kubernetes package as typed - #2657

Merged
kubernetes-prow[bot] merged 2 commits into
kubernetes-client:masterfrom
tamird:prototype/mark-kubernetes-package-typed
Jul 30, 2026
Merged

Mark the Kubernetes package as typed#2657
kubernetes-prow[bot] merged 2 commits into
kubernetes-client:masterfrom
tamird:prototype/mark-kubernetes-package-typed

Conversation

@tamird

@tamird tamird commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Python type checkers recognize a typed distribution only when py.typed is installed in its top-level package. The generated clients place markers under kubernetes.client and kubernetes.aio.client, so Pylance cannot discover the existing precise nested model annotations from the published kubernetes package.

Include kubernetes/py.typed in both the wheel and source distribution while retaining the generated client marker. Cover the synchronous and asynchronous V1Pod.status, container_statuses, and container-state type chains.

Addresses #2608 (comment).

/kind bug

Expose nested Kubernetes model type information to Python type checkers and IDEs.

Python type checkers look for py.typed at the root of an installed package. The generated synchronous and asyncio clients mark their nested packages, but the Kubernetes distribution omitted kubernetes/py.typed, so nested model fields were treated as unknown despite precise generated annotations.

Package the root marker in source and wheel distributions, retain the existing client marker, and cover nested synchronous and asyncio model types.

Refs kubernetes-client#2608.
@kubernetes-prow kubernetes-prow Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels Jul 29, 2026
@kubernetes-prow
kubernetes-prow Bot requested review from roycaihw and yliaog July 29, 2026 20:50
@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 29, 2026
Comment thread setup.py
package_data={
'kubernetes': ['py.typed'],
'kubernetes.client': ['py.typed'],
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

setup-release.py also need this ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@yliaog Yes—good catch. setup-release.py builds the combined synchronous and asyncio distribution, so updating only setup.py would leave published releases untyped.

Fixed in ca7fa34. I built the release wheel and source distribution and confirmed that both include kubernetes/py.typed as well as the existing synchronous and asyncio client markers. The nested-type regressions pass for both clients.

[tamirdex]

The combined synchronous and asyncio release uses setup-release.py rather than setup.py. Include the top-level PEP 561 marker in its package data so published release wheels expose the same nested model types as source installations.
@yliaog

yliaog commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 30, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tamird, yliaog

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 30, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit e987c5a into kubernetes-client:master Jul 30, 2026
10 checks passed
@tamird
tamird deleted the prototype/mark-kubernetes-package-typed branch July 30, 2026 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants