New import-error findings starting in 2021.12.08
We just upgraded from pytype 2021.11.29 to 2021.12.8, and we're getting errors like this now:
FAILED: /home/runner/work/python-spanner-orm/python-spanner-orm/.pytype/pyi/spanner_orm/table_apis.pyi
/opt/hostedtoolcache/Python/3.8.12/x64/bin/python -m pytype.single --imports_info /home/runner/work/python-spanner-orm/python-spanner-orm/.pytype/imports/spanner_orm.table_apis.imports --module-name spanner_orm.table_apis -V 3.8 -o /home/runner/work/python-spanner-orm/python-spanner-orm/.pytype/pyi/spanner_orm/table_apis.pyi --analyze-annotated --nofail --quick /home/runner/work/python-spanner-orm/python-spanner-orm/spanner_orm/table_apis.py
File "/home/runner/work/python-spanner-orm/python-spanner-orm/spanner_orm/table_apis.py", line 20, in <module>: Can't find module 'google.cloud.spanner'. [import-error]
For more details, see https://google.github.io/pytype/errors.html#import-error
The relevant line is a straightforward import and google-cloud-spanner appears to be installed.
That's really strange! I was able to reproduce this error, and it indeed seems to have been introduced between 2021.11.29 and 2021.12.8, but I don't see any changes that could lead to import resolution changing. I'll keep investigating.
The issue appears to be somehow caused by eccb7b3c74096a1ae277ca9f691af4cbb8ab2bc3 - if I checkout the typeshed submodule at the previous commit it was at, the error goes away.
Oh, I bet the problem is the addition of the google-cloud-ndb stubs: https://github.com/python/typeshed/tree/master/stubs/google-cloud-ndb. The stubs for that package have a google/cloud/ subdirectory, so pytype looks in there for google/cloud/spanner, but of course it doesn't exist.
I'm experiencing this error when importing google-cloud-bigquery, too.
...
in <module>: Can't find module 'google.cloud.bigquery'.