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

type issue: "StreamGenerator" is not iterable #947

Closed
shooit opened this issue Aug 12, 2024 · 4 comments · Fixed by #938
Closed

type issue: "StreamGenerator" is not iterable #947

shooit opened this issue Aug 12, 2024 · 4 comments · Fixed by #938
Assignees
Labels
api: firestore Issues related to the googleapis/python-firestore API.

Comments

@shooit
Copy link

shooit commented Aug 12, 2024

This issue was introduced with the changes in 2.17.0. It exists for each of the pyright version I tested at random.

It is only a type issue -- the code behaves as expected.

Environment details

  • OS type and version: MacOS
  • Python version: python --version 3.11.7
  • pip version: pip --version poetry
  • google-cloud-firestore version: pip show google-cloud-firestore 2.17.0
  • pyright version: 1.1.375

Steps to reproduce

  1. Setup environment as above
  2. Run pyright

Code example

client = firestore_v1.Client()


def example():
    collection = client.collection("foo")
    docs = collection.stream()
    for doc in docs:
        print(doc)
image

Error message

eample.py
  example.py:7:20 - error: "StreamGenerator" is not iterable
    "__next__" method not defined on type "DocumentSnapshot" (reportGeneralTypeIssues)
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/python-firestore API. label Aug 12, 2024
@daniel-sanche
Copy link
Contributor

Thanks for letting us know. We're aware that the type annotations for this repo are currently broken. But @Linchin is working on some changes related to the StreamGenerator, so maybe this can be addressed there

@Linchin
Copy link
Contributor

Linchin commented Aug 15, 2024

The type annotation changes in #938 should be able to resolve this error, but I don't think this single PR will clean up all existing type annotation errors.

@jekozyra
Copy link

fyi, this is broken for AsyncStreamGenerator as well.

@Linchin
Copy link
Contributor

Linchin commented Aug 28, 2024

It can be fixed by adding type annotation to the init function of StreamGenerator here. I'm still not 100% sure, but it feels like pyright is trying to infer the parameter type, but somehow wasn't correct (probably due to other type annotation errors.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/python-firestore API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants