-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Add type hints to project #2033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @kasium |
The idea would be to add type hints as described in PEP 484, decide on a type checker (like mypy, pyright, ...) and this to the CI and publish kubernetes as a typed package (by adding a magic With that, IDEs as was tools like mypy can help the user to pick the right types for functions, etc. |
maybe this is a dup of #1984 |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
/remove-lifecycle rotten |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
/remove-lifecycle rotten |
/remove-lifecycle stale |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
/remove-lifecycle rotten |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle rotten |
/remove-lifecycle stale |
In my project, we use typed dataclasses to represent kubernetes's resources. Using typed dataclasses provides benefits such as type-based code completion and static checking. It would be nice if the official SDK supports such type hints. An example of typed dataclasss generated from OpenAPI. @dataclasses.dataclass(kw_only=True)
class Container:
args: builtins.list[builtins.str] | None = dataclasses.field(
default=None, metadata={"name": "args"}
)
command: builtins.list[builtins.str] | None = dataclasses.field(
default=None, metadata={"name": "command"}
)
env: builtins.list[models.io.k8s.api.core.v1.EnvVar] | None = (
dataclasses.field(default=None, metadata={"name": "env"})
)
env_from: (
builtins.list[models.io.k8s.api.core.v1.EnvFromSource] | None
) = dataclasses.field(default=None, metadata={"name": "envFrom"})
image: builtins.str | None = dataclasses.field(
default=None, metadata={"name": "image"}
)
... Note that we developed a generator to convert OpenAPI schemas to these dataclasses. |
It would be great of the python client to add inline type hints, so that e.g. mypy can detect issues
The text was updated successfully, but these errors were encountered: