6

pyright reports both missing imports (could not be resolved) and general type errors (unknown import symbol). These libraries all exist -- I can run the code in ipython without errors. I'm using poetry to manage my virtual environment. My venv is active.

The virtualenv info:

Virtualenv
Python:         3.10.1
Implementation: CPython
Path:           /Users/jayed/Library/Caches/pypoetry/virtualenvs/create-cluster-PmxHvHbg-py3.10
Valid:          True

My pyrightconfig.json

{
  "venvPath": "/Users/jayed/Library/Caches/pypoetry/virtualenvs",
  "venv": "create-cluster-PmxHvHbg-py3.10"
}

pyright output

Loading configuration file at /Users/jayed/repos/create_cluster/pyrightconfig.json
Assuming Python version 3.10
Assuming Python platform Darwin
Auto-excluding **/node_modules
Auto-excluding **/__pycache__
Auto-excluding **/.*
stubPath /Users/jayed/repos/create_cluster/typings is not a valid directory.
Searching for source files
Found 1 source file
pyright 1.1.255
/Users/jayed/repos/create_cluster/create_cluster/create_cluster.py
  /Users/jayed/repos/create_cluster/create_cluster/create_cluster.py:49:6 - error: Import "google.iam.v1" could not be resolved (reportMissingImports)
  /Users/jayed/repos/create_cluster/create_cluster/create_cluster.py:50:6 - error: Import "google.iam.v1.policy_pb2" could not be resolved (reportMissingImports)
  /Users/jayed/repos/create_cluster/create_cluster/create_cluster.py:43:26 - error: "assuredworkloads_v1" is unknown import symbol (reportGeneralTypeIssues)
  /Users/jayed/repos/create_cluster/create_cluster/create_cluster.py:44:26 - error: "billing_v1" is unknown import symbol (reportGeneralTypeIssues)
  /Users/jayed/repos/create_cluster/create_cluster/create_cluster.py:45:26 - error: "kms_v1" is unknown import symbol (reportGeneralTypeIssues)
  /Users/jayed/repos/create_cluster/create_cluster/create_cluster.py:46:26 - error: "resourcemanager_v3" is unknown import symbol (reportGeneralTypeIssues)
  /Users/jayed/repos/create_cluster/create_cluster/create_cluster.py:47:26 - error: "service_usage_v1" is unknown import symbol (reportGeneralTypeIssues)
  /Users/jayed/repos/create_cluster/create_cluster/create_cluster.py:48:26 - error: "storage" is unknown import symbol (reportGeneralTypeIssues)
8 errors, 0 warnings, 0 informations
Completed in 1.912sec
meangrape
  • 317
  • 2
  • 11

1 Answers1

-1

You can create a pyrightconfig.json file (or toml alternative) in your project root and add the two fields to it

{
  "venvPath": "ABSOLUTE_PATH_TO_YOUR_ENVS",
  "venv": "ENV_NAME"
}

where the venvPath and venv are both needed and they will eventually be concatenated as the full path to your specific env named venv.

See also: GitHub issue thread, GitHub Pyright sample config.

NeoZoom.lua
  • 2,269
  • 4
  • 30
  • 64