Apropos of nothing: has anyone had success with VS...
# development
a
Apropos of nothing: has anyone had success with VS Code auto-imports in the Pants repo without resorting to creating a
.env
file?
b
No, it adds the prefix, which is easy to strip off
a
I got annoyed enough by it after 6 months that I added a
.env
file for my own use, which actually fixes the issue. I’m just wondering if anyone’s fixed it by means that don’t mean committing a new file or adding to .gitignore
b
a
Helpful 😛
b
You can probably set some correct settings in your workspace config. I have git ignore all
.vscode
globally across my machine
a
f
FWIW, I’ve setup a checker in CI so that when a new root-level project is added, the
.env
file is updated accordingly (to keep VSCode users happy) 🙂
Copy code
$ ROOTS=$(./pants roots --roots-sep=' ')
$ python3 -c "print('PYTHONPATH=\"./' + ':./'.join(\"${ROOTS}\".split()) + ':\$PYTHONPATH\"')"
if there are three dirs in the root,
projectA
,
projectB
,
projectC
, you’ll get
Copy code
PYTHONPATH="./projectA:./projectB:./projectC:$PYTHONPATH"
a
fancy!
h
This would be super helpful to add to our docs https://www.pantsbuild.org/docs/setting-up-an-ide Anyone interested in adding that? I'm team PyCharm
f
sure thing. I think I’ll extend https://www.pantsbuild.org/docs/setting-up-an-ide#first-party-sources with VSCode .env instructions, a PR is coming
h
Thanks!! Although for that, you'd click "suggest edits" in the top right corner. Only the "reference" docs get generated from source code
f
oh sorry, completely forgotten 🙂
done! 🙂