Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
mypy plugin to dynamically define types for Kubernetes objects.
Install with pip
:
pip install kubernetes-typed
This package follows kubernetes
client versioning approach.
MAJOR.MINOR
parts of version will match client version for which stubs were generated, and PATCH
version will be stub or plugin specific updates.
Add type checks for Custom Resource Definition spec given its definition in yaml
file .
mypy
to use crd_typed
plugin:[mypy]
plugins = crd_typed.plugin
CustomResource
from crd_type import CustomResource
resource: CustomResource["relative/path/to/crd.yaml"]
You can get type definition for different parts of crd:
Get TypeDict
definition for custom resource body:
from crd_type import CustomResource
resource: CustomResource["relative/path/to/crd.yaml"]
Get definition only for resource spec
:
from crd_type import CustomResource
resource: CustomResource["relative/path/to/crd.yaml", "spec"]
Get definition for nested spec item, if that item is type object
or array
:
from crd_type import CustomResource
resource: CustomResource["relative/path/to/crd.yaml", "spec", "some_property"]
Get definition for array item, if that is array of objects, via items
key:
from crd_type import CustomResource
resource: CustomResource["relative/path/to/crd.yaml", "spec", "some_array_of_objects", "items"]
additionalProperties
are not supported.versions
, currently only first one will be usedx-kubernetes-int-or-string
, x-kubernetes-embedded-resource
, are not supportedThis package provides basic type stubs for kubernetes python client out of the box.
To enable full type checking for classes use provided kubernetes_typed
plugin. This plugin requires kubernetes
, you can require it during installation like this:
pip install kubernetes-typed[client]
Configure mypy
to use it and it will automatically type check classes from kubernetes.client
:
[mypy]
plugins = kubernetes_typed.plugin
If you want to type check resource dicts instead of classes, you can use generated TypedDict
s provided by this package.
To do this for any model class in kubernetes.client
append its name with Dict
, and import it from kubernetes_type.client
For example:
kubernetes.client.V1Pod
-> kubernetes_typed.client.V1PodDict
from kubernetes.client.api import core_v1_api
from kubernetes_typed.client import V1PodDict
api_instance = core_v1_api.CoreV1Api()
pod_manifest: V1PodDict = {
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name": "test-pod"},
"spec": {
"containers": [
{
"image": "nginx",
"name": "nginx",
},
],
},
}
api_instance.create_namespaced_pod(body=pod_manifest, namespace='default')
Call to untyped function
errors. Check mypy config doc on how to disable separate warnings.FAQs
Collection of mypy plugins and stubs for kubernetes
We found that kubernetes-typed demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.