https://pantsbuild.org/ logo
#development
Title
# development
a

ancient-vegetable-10556

01/10/2022, 5:24 PM
Apropos of nothing: has anyone had success with VS Code auto-imports in the Pants repo without resorting to creating a
.env
file?
b

bitter-ability-32190

01/10/2022, 5:30 PM
No, it adds the prefix, which is easy to strip off
a

ancient-vegetable-10556

01/10/2022, 5:32 PM
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

bitter-ability-32190

01/10/2022, 5:33 PM
a

ancient-vegetable-10556

01/10/2022, 5:35 PM
Helpful 😛
b

bitter-ability-32190

01/10/2022, 5:39 PM
You can probably set some correct settings in your workspace config. I have git ignore all
.vscode
globally across my machine
a

ancient-vegetable-10556

01/10/2022, 5:54 PM
f

fresh-cat-90827

01/10/2022, 7:33 PM
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

ancient-vegetable-10556

01/10/2022, 9:02 PM
fancy!
h

hundreds-father-404

01/13/2022, 6:02 PM
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

fresh-cat-90827

01/13/2022, 7:57 PM
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

hundreds-father-404

01/13/2022, 8:16 PM
Thanks!! Although for that, you'd click "suggest edits" in the top right corner. Only the "reference" docs get generated from source code
f

fresh-cat-90827

01/13/2022, 9:01 PM
oh sorry, completely forgotten 🙂
done! 🙂