I use pants to manage a Python project that uses protocol buffers. Pants places the generated _pb2.py
and _pb2.pyi
files under a separate dist/codegen
tree. Is it possible to get VS Code autocomplete to work when using the _pb2
modules?
The file tree looks like this:
.
|-- dist/
| `-- codegen/
| `-- src/
| `-- project/
| |-- data_pb2.py
| `-- data_pb2.pyi
`-- src/
`-- project/
|-- __init__.py
|-- code.py
`-- data.proto
And in code.py
I have import statements like this:
from project import data_pb2
I've tried setting python.analysis.extraPaths
to ["dist/codegen/src"]
in settings.json
. This makes pylance stop complaining that data_pb2
is missing. But autocomplete still does not work, and pylance has no type information for members of data_pb2
.