Skip to content

Cannot resolve google imports when types-protobuf is installed (see #2113) #3745

Closed

Description

Describe the bug
Running pyright against code including google modules results in reportMissingImport and reportGeneralTypeIssues errors. See #2113

Screenshots or Code

Could not import 'google.api_core' in file '/Users/jayed/repos/create_cluster/src/create_cluster.py'
  Looking in stubPath '/Users/jayed/repos/create_cluster/typings'
  Attempting to resolve stub package using root path '/Users/jayed/repos/create_cluster/typings'
  Attempting to resolve using root path '/Users/jayed/repos/create_cluster/typings'
  Looking in root directory of execution environment '/Users/jayed/repos/create_cluster'
  Attempting to resolve stub package using root path '/Users/jayed/repos/create_cluster'
  Attempting to resolve using root path '/Users/jayed/repos/create_cluster'
  Looking in python search path '/Users/jayed/Library/Caches/pypoetry/virtualenvs/create-cluster-PmxHvHbg-py3.10/lib/python3.10/site-packages'
  Attempting to resolve stub package using root path '/Users/jayed/Library/Caches/pypoetry/virtualenvs/create-cluster-PmxHvHbg-py3.10/lib/python3.10/site-packages'
  Resolved import with file '/Users/jayed/Library/Caches/pypoetry/virtualenvs/create-cluster-PmxHvHbg-py3.10/lib/python3.10/site-packages/google-stubs/__init__.pyi'
  Looking in python search path '/Users/jayed/repos/create_cluster'
  Attempting to resolve stub package using root path '/Users/jayed/repos/create_cluster'
  Attempting to resolve using root path '/Users/jayed/repos/create_cluster'
  Looking for typeshed stdlib path
  Looking for typeshed stdlib path
  Attempting to resolve using root path '/Users/jayed/.npm/_npx/6f75558c21262cab/node_modules/pyright/dist/typeshed-fallback/stdlib'
  Typeshed path not found
  Looking for typeshed third-party path
  Looking for typeshed stubs path
  Attempting to resolve using root path '/Users/jayed/.npm/_npx/6f75558c21262cab/node_modules/pyright/dist/typeshed-fallback/stubs/google-cloud-ndb'
  Attempting to resolve using root path '/Users/jayed/.npm/_npx/6f75558c21262cab/node_modules/pyright/dist/typeshed-fallback/stubs/protobuf'
  Resolved import with file '/Users/jayed/.npm/_npx/6f75558c21262cab/node_modules/pyright/dist/typeshed-fallback/stubs/protobuf/google/__init__.pyi'
  Typeshed path not found
... [EDITED]
pyright 1.1.263
/Users/jayed/repos/create_cluster/src/create_cluster.py
  /Users/jayed/repos/create_cluster/src/create_cluster.py:41:6 - error: Import "google.api_core" could not be resolved (reportMissingImports)

from google.api_core import client_options
Version: 2.8.2

types-protobuf version: 3.19.22

VS Code extension or command-line
pyright --verbose src/create_cluster.py

Additional context
Uninstalling types-protobuf makes the errors go away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions