Mark the Kubernetes package as typed - #2657
Conversation
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.
| package_data={ | ||
| 'kubernetes': ['py.typed'], | ||
| 'kubernetes.client': ['py.typed'], | ||
| }, |
There was a problem hiding this comment.
setup-release.py also need this ?
There was a problem hiding this comment.
@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.
|
/lgtm |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
e987c5a
into
kubernetes-client:master
Python type checkers recognize a typed distribution only when
py.typedis installed in its top-level package. The generated clients place markers underkubernetes.clientandkubernetes.aio.client, so Pylance cannot discover the existing precise nested model annotations from the publishedkubernetespackage.Include
kubernetes/py.typedin both the wheel and source distribution while retaining the generated client marker. Cover the synchronous and asynchronousV1Pod.status,container_statuses, and container-state type chains.Addresses #2608 (comment).
/kind bug