Skip to content

Add type hints to project #2033

Done
Done

Description

@kasium

It would be great of the python client to add inline type hints, so that e.g. mypy can detect issues

Activity

  1. added
    kind/feature
    on Mar 24, 2023
  2. muzakkirsaifi123 commented on Mar 27, 2023

    @muzakkirsaifi123

    Hi @kasium
    Could you please explain about it more.

  3. kasium commented on Mar 27, 2023

    @kasium
    Author

    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 py.typed file to the project).

    With that, IDEs as was tools like mypy can help the user to pick the right types for functions, etc.

  4. roycaihw commented on Mar 27, 2023

    @roycaihw
    Member

    maybe this is a dup of #1984

  5. k8s-triage-robot commented on Jun 25, 2023

    @k8s-triage-robot

    The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

    This bot triages un-triaged issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue as fresh with /remove-lifecycle stale
    • Close this issue with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle stale

  6. added
    lifecycle/stale
    on Jun 25, 2023
  7. msw-kialo commented on Nov 1, 2023

    @msw-kialo

    /remove-lifecycle stale

  8. removed
    lifecycle/stale
    on Nov 1, 2023
  9. k8s-triage-robot commented on Jan 31, 2024

    @k8s-triage-robot

    The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

    This bot triages un-triaged issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue as fresh with /remove-lifecycle stale
    • Close this issue with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle stale

  10. added
    lifecycle/stale
    on Jan 31, 2024
  11. k8s-triage-robot commented on Mar 1, 2024

    @k8s-triage-robot

    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:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue as fresh with /remove-lifecycle rotten
    • Close this issue with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle rotten

  12. added
    lifecycle/rotten
    and removed
    lifecycle/stale
    on Mar 1, 2024
  13. msw-kialo commented on Mar 18, 2024

    @msw-kialo

    /remove-lifecycle rotten

  14. removed
    lifecycle/rotten
    on Mar 18, 2024
  15. 14 remaining items

  16. removed
    lifecycle/rotten
    on Dec 2, 2024
  17. k8s-triage-robot commented on Mar 2, 2025

    @k8s-triage-robot

    The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

    This bot triages un-triaged issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue as fresh with /remove-lifecycle stale
    • Close this issue with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle stale

  18. added
    lifecycle/stale
    on Mar 2, 2025
  19. ryanpeach commented on Mar 4, 2025

    @ryanpeach

    /remove-lifecycle rotten

  20. ryanpeach commented on Mar 4, 2025

    @ryanpeach

    /remove-lifecycle stale

  21. removed
    lifecycle/stale
    on Mar 4, 2025
  22. Hakuyume commented on May 15, 2025

    @Hakuyume

    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.

  23. roycaihw commented on Jun 6, 2025

    @roycaihw
    Member

    /help

  24. k8s-ci-robot commented on Jun 6, 2025

    @k8s-ci-robot
    Contributor

    @roycaihw:
    This request has been marked as needing help from a contributor.

    Guidelines

    Please ensure that the issue body includes answers to the following questions:

    • Why are we solving this issue?
    • To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
    • Does this issue have zero to low barrier of entry?
    • How can the assignee reach out to you for help?

    For more details on the requirements of such an issue, please see here and ensure that they are met.

    If this request no longer meets these requirements, the label can be removed
    by commenting with the /remove-help command.

    Details

    In response to this:

    /help

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

  25. added
    help wanted
    on Jun 6, 2025
  26. yliaog commented on Jul 31, 2026

    @yliaog
    Contributor

    thanks @tamird for upgrading openapi generator to the latest, now the python client library has type hints. Please give it a try.

  27. yliaog commented on Nov 26, 2026

    @yliaog
    Contributor

    /close

  28. kubernetes-prow commented on Nov 26, 2026

    @kubernetes-prow
    Contributor

    @yliaog: Closing this issue.

    Details

    In response to this:

    /close

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedkind/feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions