kubernetes-client / python

Official Python client library for kubernetes
http://kubernetes.io/
Apache License 2.0
6.67k stars 3.25k forks source link

Explore the possibility of type hinting #225

Open mbohlool opened 7 years ago

mbohlool commented 7 years ago

Python 3 has a type hinting feature very useful for auto complete. This issue is for tracking efforts on researching its backward compatibility with python 2 (from __future__ import import annotations?) and if possible, change code generator to implement it. Best if we contribute it back to swagger-codegen.

fejta-bot commented 5 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot commented 5 years ago

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten

fejta-bot commented 5 years ago

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

k8s-ci-robot commented 5 years ago

@fejta-bot: Closing this issue.

In response to [this](https://github.com/kubernetes-client/python/issues/225#issuecomment-503964189): >Rotten issues close after 30d of inactivity. >Reopen the issue with `/reopen`. >Mark the issue as fresh with `/remove-lifecycle rotten`. > >Send feedback to sig-testing, kubernetes/test-infra and/or [fejta](https://github.com/fejta). >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
sebastian-philipp commented 5 years ago

Ping? This is still annoying to have no auto completion in my IDE. Any chance of getting this in?

evanmosseri commented 4 years ago

/reopen

k8s-ci-robot commented 4 years ago

@evanmosseri: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to [this](https://github.com/kubernetes-client/python/issues/225#issuecomment-529686223): >/reopen Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
sebastian-philipp commented 4 years ago

This issue is one reason I wrote my own generator: https://github.com/sebastian-philipp/rook-ceph-client-python

micw523 commented 4 years ago

/reopen

k8s-ci-robot commented 4 years ago

@micw523: Reopened this issue.

In response to [this](https://github.com/kubernetes-client/python/issues/225#issuecomment-532731028): >/reopen Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
fejta-bot commented 4 years ago

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

k8s-ci-robot commented 4 years ago

@fejta-bot: Closing this issue.

In response to [this](https://github.com/kubernetes-client/python/issues/225#issuecomment-543815520): >Rotten issues close after 30d of inactivity. >Reopen the issue with `/reopen`. >Mark the issue as fresh with `/remove-lifecycle rotten`. > >Send feedback to sig-testing, kubernetes/test-infra and/or [fejta](https://github.com/fejta). >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
micw523 commented 4 years ago

/reopen /lifecycle frozen

k8s-ci-robot commented 4 years ago

@micw523: Reopened this issue.

In response to [this](https://github.com/kubernetes-client/python/issues/225#issuecomment-543835768): >/reopen >/lifecycle frozen Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
roycaihw commented 4 years ago

Type hinting would be more useful for using the APIs in this client (compared to config-loading, watch, etc), which are mostly generated by openapi-generator. I wonder if openapi-generator support type hinting.

cc @tomplus @scottilee

sebastian-philipp commented 4 years ago

In the meantime, I've made https://github.com/ceph/rook-client-python to generate client API classes for CRDs . It contains a code generator that is usable independently of this project.

If there is an interest, the code generator could certainly be moved into a dedicated project.

scottilee commented 3 years ago

Tracking here: https://github.com/OpenAPITools/openapi-json-schema-generator/issues/30

benesch commented 3 years ago

I hacked together an external type stubs package for now: https://pypi.org/project/kubernetes-stubs/. Perhaps it's of use to some other folks!

gordonbondon commented 2 years ago

For those who want to typecheck existing custom resources without generating additional code - I've created mypy plugin that can do this based on openapi spec from CRD yamls https://pypi.org/project/kubernetes-typed/.

shinebayar-g commented 2 years ago

This is such a needed feature :smiling_face_with_tear:

roycaihw commented 2 years ago

/help

k8s-ci-robot commented 2 years ago

@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:

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.

In response to [this](https://github.com/kubernetes-client/python/issues/225): >/help Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
lexdene commented 1 year ago

I hacked together an external type stubs package for now: https://pypi.org/project/kubernetes-stubs/. Perhaps it's of use to some other folks!

kubernetes-stubs has not provided stubs for kubernetes >= 23.0 yet (2023-06-03).

I forked it to kubernetes-stubs-elephant-fork which provides stubs for all releases after 7.0 of kubernetes, even includes any release in the future automatically.

I run a crontab by github actions which looks for new releases of kubernetes and build typing stubs for it.

guyarad commented 3 months ago

How is this feature not being provided by the main k8s client library for Python?