Registry / type-stubs / kubernetes-stubs-elephant-fork

kubernetes-stubs-elephant-fork

JSON →
library36.0.2pypypiunverified

This library provides type stubs for the official Kubernetes Python API client. It is an actively maintained fork of the original `kubernetes-stubs` package, offering static type checking support for projects using the `kubernetes` client. The current version is 35.0.0.post1, with a frequent release cadence aimed at keeping pace with upstream `kubernetes` client updates.

pip install kubernetes-stubs-elephant-fork
INSTALL
IMPORT
SIG · KUBERNETES-STUBS-E
K
kubernetes-stubs-elephant-fork
type-stubspythonv36.0.2
Install
1.8s avg
Import
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v36.0.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 22.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.8s · import 0.000s · 23MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

client
from kubernetes_ext import client
from kubernetes_stubs import client

This quickstart demonstrates how `kubernetes-stubs-elephant-fork` provides type hints for code that uses the `kubernetes` client library. The stubs are automatically picked up by type checkers like MyPy, without requiring direct imports from the stub package. The `if __name__ == "__main__"` block provides a runnable example requiring Kubernetes connectivity.

import os from kubernetes import client, config from typing import TYPE_CHECKING # This function will only execute at runtime, not during type checking if not TYPE_CHECKING: # Load Kubernetes configuration # For local development, e.g., ~/.kube/config try: config.load_kube_config(context=os.environ.get('KUBE_CONTEXT', '')) except config.config_exception.ConfigException: # Fallback for CI/CD or in-cluster config.load_incluster_config() def get_pod_names(namespace: str) -> list[str]: # The type checker uses kubernetes-stubs-elephant-fork here v1: client.CoreV1Api = client.CoreV1Api() # The return type of list_namespaced_pod is typed by the stubs pods_list = v1.list_namespaced_pod(namespace=namespace) names: list[str] = [] for pod in pods_list.items: if pod.metadata and pod.metadata.name: names.append(pod.metadata.name) return names if __name__ == "__main__": # Example runtime usage (requires a running Kubernetes cluster/config) try: # Replace 'default' with your target namespace or use env var target_namespace = os.environ.get('KUBE_NAMESPACE', 'default') pod_names = get_pod_names(target_namespace) print(f"Pods in '{target_namespace}' namespace: {pod_names}") except Exception as e: print(f"Could not list pods (is Kubernetes configured?): {e}") # To type-check this file: # 1. pip install mypy kubernetes kubernetes-stubs-elephant-fork # 2. mypy quickstart.py
Debug
Known issues
gotchaThe version number of `kubernetes-stubs-elephant-fork` does not directly correspond to the `kubernetes` client version it supports. For example, `kubernetes-stubs-elephant-fork==35.0.0.post1` targets `kubernetes>=28.0.0`. Always consult the stub package's README or changelog to confirm compatibility with your specific `kubernetes` client version to avoid unexpected type errors.
fix
Refer to the `kubernetes-stubs-elephant-fork` GitHub README for the exact `kubernetes` client version range supported by your installed stub version.
affects: All versions
gotcha`kubernetes-stubs-elephant-fork` contains only type stubs and is not meant for direct runtime import or execution. Attempting to `from kubernetes_stubs_elephant_fork import ...` will lead to a `ModuleNotFoundError` or similar runtime error.
fix
Always import symbols from the actual `kubernetes` client library (e.g., `from kubernetes import client`). The stub package is automatically discovered by type checkers.
affects: All versions
gotchaIf migrating from the unmaintained original `kubernetes-stubs` package, it is crucial to uninstall it to prevent potential conflicts or incorrect stub resolution by your type checker.
fix
Run `pip uninstall kubernetes-stubs` before or after installing `kubernetes-stubs-elephant-fork`.
affects: Users migrating from `kubernetes-stubs`
Upgrade
Version history
36.0.2latest on PyPI · released Jun 1, 2026
Audit
Dependencies
kubernetesrequiredProvides type hints for the kubernetes client library; essential for its utility, though not a runtime dependency for the stubs package itself.
Agent activity
37 hits · last 30 days
node
34
OpenAI (training)
2
Resources
kubernetes-stubs-elephant-fork — pip install kubernetes-stubs-elephant-fork · libregistry