Skip to content
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

kr8s.api.get returns async APIObject, would expect sync objects #555

Closed
ion-elgreco opened this issue Jan 22, 2025 · 5 comments · Fixed by #556
Closed

kr8s.api.get returns async APIObject, would expect sync objects #555

ion-elgreco opened this issue Jan 22, 2025 · 5 comments · Fixed by #556
Labels
bug Something isn't working typing

Comments

@ion-elgreco
Copy link

Which project are you requesting an enhancement for?

kr8s

What do you need?

Doing get on the api returns a generator of APIObjects but this class doesn't have the sync methods.

from kr8s.objects import Pod
api.get(
                    Pod,
                    label_selector="value",
                    namespace=config.namespace,
                )
@ion-elgreco ion-elgreco added the enhancement New feature or request label Jan 22, 2025
@jacobtomlinson
Copy link
Member

I'm not able to reproduce this one.

>>> import kr8s
>>> api = kr8s.api()
>>> pods = list(api.get(kr8s.objects.Pod))

>>> type(pods[0])
<class 'kr8s.objects.Pod'>

>>> pods[0]._asyncio
False

>>> type(pods[0].get)
<class 'method'>

@jacobtomlinson
Copy link
Member

Also tried with the same kwargs to make sure that wasn't the problem, but can't reproduce with that either.

>>> pods = list(api.get(kr8s.objects.Pod, label_selector={'run': 'foo'}, namespace="default"))
>>> type(pods[0])
<class 'kr8s.objects.Pod'>
>>> pods[0]._asyncio
False
>>> type(pods[0].get)
<class 'method'>

@ion-elgreco
Copy link
Author

ion-elgreco commented Jan 22, 2025

@jacobtomlinson pylance (pyright) is saying it:

Image

Image

@ion-elgreco
Copy link
Author

ion-elgreco commented Jan 22, 2025

It might be the correct class, but static type checkers are not recognizing it since I guess you made it dynamic. The typehint says it returns an APIObject generator, which only has the async methods.

@jacobtomlinson
Copy link
Member

Ah I see, it doesn't actually return that type, but it hints that it does. Fixed in #556.

@jacobtomlinson jacobtomlinson added bug Something isn't working typing and removed enhancement New feature or request needs reproducible example labels Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working typing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants