-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate where we should implicitly trigger the Python: Create Environment
command
#20133
Comments
We can start with option 2 as it shouldn't be hard to expand it to 1 if we want to? |
Related: #4606. If we were to add such a prompt it could be used here. |
Investigate where we should implicitly trigger the First school of thought are ideas that would result in triggers upon open.
Alternatively, we can look at "just in time" triggers. A few ideas on what this can look like:
Final area of thought revolves around increased discoverability of the
All of these items would require further discussion and partnership to execute but something to get the wheels turning :) |
I particularly like the idea of only showing it when people try to run or debug a file but there are unresolved imports in their file (even better if it's in the workspace). @karrtikr do you know whether this is possible today? I.e. does the Python extension get such context from Pylance? |
This comment was marked as resolved.
This comment was marked as resolved.
Yes, we can use |
Create Environment
commandPython: Create Environment
command
The problem with the get diagnostics solution (at least if you're using pylance) is that we only report diagnostics for open files. Not every file in the workspace (unless the user changes a setting). However, there is a way to query pylance for the diagnostics for a specific file. We don't currently support this method (AFAICT) but shouldn't be too hard to add. (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_diagnostic) So instead of querying the problems window, you'd query pylance with the file path to the requirements.txt or the pyproject.toml file. |
Here we're only trying to see if the file which is to be run or debugged has unresolved imports, so it should be open. Also I'm not sure we should querying for every closed file in the repository as that would mean Pylance has to analyze the entire repository and not just the opened files. |
Sorry I misunderstood, I thought you were querying the requirements.txt file for unresolved imports. I meant this wouldn't show any unresolved imports unless it was already open. If you only need the unresolved import for the python file, then it should already work. |
we ended up going with a notification prompt being shown when users attempt to run code (through any of our run commands like run in terminal or run selection in terminal, or when they start debugging), AND the following conditions are met:
|
This is the issue tracking the work: #21965 |
Two options:
pyproject.toml
orrequirements.txt
file in the workspace, run theCreate Environment
command (or ask the user to select a virtual environment or create environment)The text was updated successfully, but these errors were encountered: