https://pantsbuild.org/ logo
r

ripe-gigabyte-88964

04/05/2023, 5:32 PM
Do any of the maintainers use vscode? Trying to develop a plugin but I can't get vscode quick fix to work 🙁
w

wide-midnight-78598

04/05/2023, 6:40 PM
Are you building off of the pants mainline? Or an external pants plugin?
r

ripe-gigabyte-88964

04/05/2023, 6:41 PM
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

wide-midnight-78598

04/05/2023, 6:43 PM
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

ripe-gigabyte-88964

04/05/2023, 6:45 PM
just the microsoft provided python extensions
side note: is suspenders any good?
w

wide-midnight-78598

04/05/2023, 6:46 PM
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

ripe-gigabyte-88964

04/05/2023, 6:52 PM
maybe some magic config setting in
.vscode/settings.json
?
w

wide-midnight-78598

04/05/2023, 6:53 PM
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

ripe-gigabyte-88964

04/05/2023, 7:01 PM
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

wide-midnight-78598

04/05/2023, 7:01 PM
you have a pants-plugins folder in the main pants repo?
r

ripe-gigabyte-88964

04/05/2023, 7:02 PM
I'm realizing I misunderstood your original question about external plugin vs pants mainline. This is a plugin in my team's repo.
w

wide-midnight-78598

04/05/2023, 7:03 PM
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

breezy-apple-27122

04/11/2023, 11:53 AM
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

wide-midnight-78598

04/11/2023, 12:00 PM
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.