-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
module google.cloud has no attribute firestore - Incorrect #12985
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
Comments
Are you using 0.950 should have fixes for all known incremental mode bugs, in particular, #12250 . If you do get a repro, that would be helpful. |
Will try and see if it fixes |
It has no effect unfortunately - which is unsurprising anyway because then we'd have to understand why For now, we will just |
I'm seeing a similar behavior - with: from google.cloud import bigquery, storage I get:
This is with mypy 0.961; I was able to work around it for now by doing: from google.cloud import bigquery
from google.cloud.storage import Client as StorageClient which of course may not work for everyone, but for me it's good enough. I am not sure why it would work, but it does. EDIT: this is on Python 3.10.2 + Poetry |
Okay, had some free time, so looked into this. There are a couple different things alluded to in this issue: The first issue is that google-cloud-firestore (and google-cloud-storage) are not py.typed packages. This means that mypy does not know anything about them and things are expected to fail. Note that google-cloud-bigquery does have a py.typed, which is why it doesn't cause any issues.
The second issue is that mypy gives an unhelpful diagnostic / gives a diagnostic with an inconsistent error code in cases involving multiple imports from the same namespace package ("no attribute" instead of the clearer message mentioning py.typed above). See #10360 for more details. I believe this issue is mainly just a duplicate of that one, so I'll be closing this. The third issue (alluded to here, but without repro) is with incremental mode. Several issues with these have been fixed, but there is one recently reported issue that is not yet fixed, see #13085. I'll have a fix for this soon (which should hopefully be more robust than patches to similar prior issues). |
* run mypy in CI * more type hint fixing * Update requirements.txt * google.cloud import workaround python/mypy#10360 * Revert "google.cloud import workaround" This reverts commit e03dbc7. * mypy google.cloud workaround python/mypy#12985 * fix regular tests * remove --install-types flag * last mypy fix * type fixes for address_reasons * move email lists creation * update for newly merged changes * Fix regular tests * Changes suggested by @jrobbins * Catch invalid requests * small type hint * Change methods to properly override * revert to previous implementation * revert test * add back original validate request type method * remove unused import and rearrange methods * remove comment string casting; add test back * add ndb ignore * Update test_html_rendering.html * mypy fix * remove merge addition
Bug Report
module google.cloud has no attribute firestore
The bug is that this statement is not true.
There have been a few related stackoverflow issues (e.g. 1, 2) relating to incorrect "module x as no attribute y" specifically relating to google.cloud.
Some issues were sorted by recreating the virtual env.
Other issues on this repo were historically traced back to using incremental mode but solution seemed incomplete (e.g. 1, 2).
We disabled mypy cache (e.g. incremental mode) which dealt with a chunk of the problem
To Reproduce
Hard to know exactly how to reproduce because the problem with this issue is it seems random and indeterministic - even after disabling incremental mode.
All I can tell you is in our code we do:
Both
google-cloud-bigquery
andgoogle-cloud-firestore
are in setup.cfg/requirements.txt and installed in the virtual environment which mypy is being activated from.We have no issues (currently) with the bigquery import but we do with firestore. They are completely identical for all intents and purposes here.
Expected Behaviour
No complaint about missing attribute.
Actual Behaviour
Incorrect complaint about missing attribute.
Your Environment
mypy 0.950 (compiled: yes)
python 3.9.x
Please can we get to the bottom of this once and for all?
The text was updated successfully, but these errors were encountered: