Skip to content

Declare __all__ in public subpackages - #2725

Merged
kubernetes-prow[bot] merged 1 commit into
kubernetes-client:masterfrom
r4victor:fix-reexports
Oct 8, 2026
Merged

kubernetes-prow[bot] merged 1 commit into
kubernetes-client:masterfrom
r4victor:fix-reexports

Conversation

@r4victor

@r4victor r4victor commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

Add __all__ to kubernetes.config, kubernetes.stream, kubernetes.utils, kubernetes.watch and their kubernetes.aio counterparts so that type checkers treat their documented functions and classes as public, which they stopped doing once the package shipped py.typed.

Which issue(s) this PR fixes:

Fixes #2724

Special notes for your reviewer

  • Why __all__ rather than as aliases: kubernetes.informer and kubernetes.aio already declare their exports with __all__, and it leaves the existing imports untouched.
  • Why no tests: CI doesn't run a type checker, and that's the only place the failure shows up.
    • A runtime check that every imported name is in __all__ would wrongly fail when a name is imported for internal use only.
    • A hardcoded list of names would just duplicate __all__.
    • A type checker in CI would be the real guard, but that's a bigger change than this fix.

Does this PR introduce a user-facing change?

Fixed type checkers such as pyright reporting documented functions and classes in `kubernetes.config`, `kubernetes.stream`, `kubernetes.utils`, `kubernetes.watch` and their `kubernetes.aio` counterparts, for example `config.load_kube_config` and `utils.create_from_yaml`, as not exported since v37.0.0. Wildcard imports such as `from kubernetes.config import *` no longer import unrelated names like `exists` and `expanduser`.

The py.typed marker makes type checkers treat names imported in __init__.py as private unless they are re-exported, so pyright rejected documented calls such as utils.create_from_yaml and config.load_kube_config.
@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 Oct 8, 2026
@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: r4victor / name: Victor Skvortsov (520673c)

@kubernetes-prow
kubernetes-prow Bot requested review from roycaihw and yliaog October 8, 2026 07:06
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Welcome @r4victor!

It looks like this is your first PR to kubernetes-client/python 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-client/python has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@kubernetes-prow kubernetes-prow Bot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Oct 8, 2026
@yliaog

yliaog commented Oct 8, 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 Oct 8, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: r4victor, 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 Oct 8, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit 9c5f434 into kubernetes-client:master Oct 8, 2026
10 checks passed
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.

Since 37.0.0, kubernetes.utils breaks the typing spec's rules leading to pyright errors

2 participants