cool-printer-74432
06/06/2022, 10:45 PMdist/codegen
? E.g., _pb2.py
from protobuf_sources
. Pointing VSCode at the virtualenv created by pants export
gives me a mostly usable VSCode experience, but I still get mypy errors inside VSCode about missing _pb2
modules. I found that I can add symlinks in the same directories as my .proto
files that point to the generated files in dist/codegen
. And add *_pb2.py
and *_pb2.pyi
to .gitignore
. But this feels, uh, pretty kludgy.high-yak-85899
06/06/2022, 10:59 PM.vscode/settings.json
file
"python.analysis.extraPaths": [
"dist/codegen/<source root here>",
"dist/codegen/<another source root here>"
]
cool-printer-74432
06/06/2022, 11:28 PM.proto
files in the same dir as code that uses them? E.g., I have something like awesome/data.proto
and awesome/stuff.py
which has a from awesome import data_pb2
.high-yak-85899
06/06/2022, 11:29 PM<source root here>
came from source.root_patterns
in my pants.toml
file.cool-printer-74432
06/07/2022, 12:07 AMquaint-forest-8735
06/07/2022, 1:19 PMdist/codegen
— once we isolated the python source tree everything workedcool-printer-74432
06/08/2022, 5:03 AM"python.analysis.extraPaths"
Just Works for some. PEP 420 (implicit namespace packages) means that Python will merge packages in different directories as long as none of the directories have an __init__.py
. So removing the __init__.py
file from my checked in source directory means that Python can merge the checked in source and the codegen source as part of the same package, and everything seems to work.