Do any of the maintainers use vscode? Trying to de...
# general
r
Do any of the maintainers use vscode? Trying to develop a plugin but I can't get vscode quick fix to work 🙁
w
Are you building off of the pants mainline? Or an external pants plugin?
r
Pants mainline, my virtualenv recognizes the dependencies once I add the import manually but I can't get it to find it unless I provide the path first
w
Oh, that was the opposite of what I was expecting. Let me open up a repo and see what happens - I recall this happening to me, but for external plugins
🙏 1
Hrmmmm - which extensions do you use?
Sorry, ignore Suspenders - that's irrelevant to this
r
just the microsoft provided python extensions
side note: is suspenders any good?
w
is suspenders any good?
It will be once I'm done building it 🙂
🤣 1
🎉 2
just the microsoft provided python extensions
Okay, that's strange - I don't use a venv - and my quick fixes pop up no problem... Hrmmmmm
Ah, you know what - let me check in files that have no Pants imports already
🙏 1
ha, that's hilarious - worked on vscode open, then I created a do-nothing file to test against, and now I lost all my quick fixes 🤦‍♂️
r
maybe some magic config setting in
.vscode/settings.json
?
w
Okay, yeah - no magic, I close my VSCode, re-open and it runs. I think there is some intellisense cache than can be manually cleared?
However, to kinda echo your point - I've noticed over the past year or so that my Pants quick-fixes and auto-complete are unreliable in VSCode depending on the weather. 95% of the time, no problem, but sometimes this happens where it's like vscode forgets what I'm doing. Usually fixed by a vscode close and re-open "unfortunately".
Also, another thing to check (and I'm sure I've set this up once and long-since forgotten). You might be able to manually add some paths - but in my case, usually I've blundered on my pylance config (e.g. apparently I don't have auto-import as a suggestion setup)
r
Yeah I'm realizing my auto-import for my
pants-plugins
folder seems totally borked, probably because it's a different venv and source root than the rest of my project
w
you have a pants-plugins folder in the main pants repo?
r
I'm realizing I misunderstood your original question about external plugin vs pants mainline. This is a plugin in my team's repo.
w
Ahhhhhh
Okay, yes - this is still a problem for me that I noticed yesterday. Was just unrelatedly working on trying to fix it. I'll report back if I get it solved
🙏 1
🎉 1
Yep - still a problem after all my pylance stuff - I have some ideas though
Settings.json - this appears to work
Copy code
{
  "python.analysis.packageIndexDepths": [
    {
      "name": "pants",
      "depth": 4,
      "includeAllSymbols": true
    }
  ]
}
Might need to re-install pants into your venv to kick it off and increase the depth depending.
b
If you
pants export --resolve=python-default --resolve=pytest --resolve=autoflake --resolve=black --resolve=isort --resolve=flake8 --resolve=mypy
to export your venv, then you can configure the
.vscode/settings.json
file like this:
Copy code
{
  "python.analysis.typeCheckingMode": "basic",
  "python.analysis.indexing": true,
  "python.analysis.autoImportCompletions": true,
  "python.defaultInterpreterPath": "${workspaceFolder}/dist/export/python/virtualenvs/python-default/3.11.2/pex",
  "editor.formatOnSave": true,
  "python.formatting.blackArgs": [
    "--line-length=120",
    "--target-version=py311",
    "--include='\\\\.py$'"
  ],
  "python.formatting.blackPath": "${workspaceFolder}/dist/export/python/virtualenvs/black/3.11.2/pex",
  "python.formatting.provider": "black",
  "python.linting.flake8Enabled": true,
  "python.linting.flake8Path": "${workspaceFolder}/dist/export/python/virtualenvs/flake8/3.11.2/pex",
  "python.linting.mypyPath": "${workspaceFolder}/dist/export/python/virtualenvs/mypy/3.11.2/pex",
  "python.linting.mypyEnabled": true,
  "python.linting.mypyArgs": [
    "--follow-imports=silent",
    "--ignore-missing-imports",
    "--show-column-numbers",
    "--no-pretty",
    "--install-types",
    "--namespace-packages",
    "--explicit-package-bases"
  ],
  "files.associations": {
    "BUILD": "python"
  }
}
🎉 1
w
It'd be cool if we could also export a vscode settings snippet, or if this is something the plugin can handle. Not sure if plugins can alter another plugin's settings.