-
Notifications
You must be signed in to change notification settings - Fork 78
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
google.cloud.firestore
lacks packaged typing
#447
Comments
If that |
Hiya - thanks for looking Take a look at #448 which would fix this by renaming It's just that according to PEP561, typing information is not distributed to module-only distributions (eg Type checkers (mypy / pyright) will not currently locate types for from google.cloud.firestore import AsyncClient
reveal_type(AsyncClient) # will reveal as `Any` until #448 lands. |
@nipunn1313 Because |
Thanks for the clarification!
from google.cloud.firestore import AsyncClient as AC1
from google.cloud.firestore_v1 import AsyncClient as AC2
reveal_type(AC1)
reveal_type(AC2) mypy:
pyright
I think there might be some ambiguity in the terminology and spec of PEP561 here - particularly around requirements for modules within namespace packages. I'm in the process of trying to clarify this python/peps#2083, so any feedback appreciated. See this comment microsoft/pyright#2113 (comment) for some of the intention typecheckers rely on a I don't think the PEP explains how to indicate types for something like
My inference here - is that it's encouraging |
Hi @tseaver - the PEP-561 was just updated (by me) (python/peps#2083) to clarify this case. It now states:
here - |
I'm against a change which would make |
Appreciate you for promptly taking a look and replying. I don't really have a vested interest in the issue (I merely work on mypy and mypy-protobuf and noticed the issue in my travels), so I won't push further. I am confused by your logic, but it's not my judgement call to make.
I do want to clarify for future readers that the two major typecheckers (mypy and pyright) are operating exactly to spec here. They certainly can figure out the types of reexported symbols - but they are expected to avoid investigating packages without If you (future reader) find that you don't have types and you'd like them - avoid the from google.cloud.firestore import AsyncClient as AC1
from google.cloud.firestore_v1 import AsyncClient as AC2
reveal_type(AC1) # Any
reveal_type(AC2) # Type[AsyncClient] |
I would note that the example usage in your README won't get types since it does |
#476 improved on types, but we have a bit of a gap to close yet. currently the code as merged is validating the package, google.cloud.firestore. We want to evaluate mypy against google and tests Once https://www.github.com/googleapis/gapic-generator-python/issues/1026 is addressed, we should be unblocked to wrap this up. |
Hi.
google.cloud.firestore
does not have types via PEP561google.cloud.firestore_v1
and friends do.Per the PEP:
You'll have to refactor
firestore.py
into a directory structureRepro steps:
The text was updated successfully, but these errors were encountered: