Skip to content

Cannot resolve google.cloud imports when types-protobuf are installed #2113

Closed
@nullie

Description

@nullie

Describe the bug
When types-protobuf stub is installed, google.cloud imports cannot be resolved. I don't think it's a stub bug, because mypy seems to handle this right.

To Reproduce
In a fresh venv:

pip install types-protobuf
pip install google-cloud-firestore
cat > test.py
from google.cloud import firestore
^D
npx pyright --verbose

No configuration file found.
No pyproject.toml file found.
stubPath /home/nullie/work/pyright-bug/typings is not a valid directory.
Assuming Python platform Linux
Search paths for /home/nullie/work/pyright-bug
  /home/nullie/work/pyright-bug/node_modules/pyright/dist/typeshed-fallback/stdlib
  /home/nullie/work/pyright-bug
  /home/nullie/work/pyright-bug/typings
  /home/nullie/work/pyright-bug/node_modules/pyright/dist/typeshed-fallback/stubs/...
  /usr/lib/python3.8
  /usr/lib/python3.8/lib-dynload
  /home/nullie/work/pyright-bug/venv/lib/python3.8/site-packages
Searching for source files
Auto-excluding /home/nullie/work/pyright-bug/venv
Found 1 source file
Could not import 'google.cloud' in file '/home/nullie/work/pyright-bug/test.py'
  Looking for typeshed stdlib path
  Attempting to resolve using root path '/home/nullie/work/pyright-bug/node_modules/pyright/dist/typeshed-fallback/stdlib'
  Typeshed path not found
  Looking in stubPath '/home/nullie/work/pyright-bug/typings'
  Attempting to resolve using root path '/home/nullie/work/pyright-bug/typings'
  Attempting to resolve using root path '/home/nullie/work/pyright-bug/typings'
  Looking in root directory of execution environment '/home/nullie/work/pyright-bug'
  Attempting to resolve using root path '/home/nullie/work/pyright-bug'
  Attempting to resolve using root path '/home/nullie/work/pyright-bug'
  Looking in python search path '/usr/lib/python3.8'
  Attempting to resolve using root path '/usr/lib/python3.8'
  Attempting to resolve using root path '/usr/lib/python3.8'
  Looking in python search path '/usr/lib/python3.8/lib-dynload'
  Attempting to resolve using root path '/usr/lib/python3.8/lib-dynload'
  Attempting to resolve using root path '/usr/lib/python3.8/lib-dynload'
  Looking in python search path '/home/nullie/work/pyright-bug/venv/lib/python3.8/site-packages'
  Attempting to resolve using root path '/home/nullie/work/pyright-bug/venv/lib/python3.8/site-packages'
  Resolved import with file '/home/nullie/work/pyright-bug/venv/lib/python3.8/site-packages/google-stubs/__init__.pyi'
  Looking for typeshed path
  Looking for typeshed stubs path
  Attempting to resolve using root path '/home/nullie/work/pyright-bug/node_modules/pyright/dist/typeshed-fallback/stubs/protobuf'
  Resolved import with file '/home/nullie/work/pyright-bug/node_modules/pyright/dist/typeshed-fallback/stubs/protobuf/google/__init__.pyi'
  Typeshed path not found
/home/nullie/work/pyright-bug/test.py
  /home/nullie/work/pyright-bug/test.py:1:6 - error: Import "google.cloud" could not be resolved (reportMissingImports)
1 error, 0 warnings, 0 infos
Completed in 0.619sec

Expected behavior
No errors

Screenshots or Code
from google.cloud import firestore

VS Code extension or command-line
Running pyright 1.1.157 with npx

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    addressed in next versionIssue is fixed and will appear in next published version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions