-
Notifications
You must be signed in to change notification settings - Fork 1.2k
If I have Python-related files in my workspace, automatically activate the extension #4765
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
Comments
I know you included etc., but I'd like to explicitly call out |
also |
@luabud we have an external PR for this issue. |
@DonJayamanne this is a change to |
Sorry, I missed that question. I.e. extension will need to modify package.json during runtime, instead of shipping it. We might need to change how this experiment works, else we'll get telemetry for users who open VSC once and we'll (via telemetry) get notified they are in the experiment, when in fact they aren't (not until they re-load VS Code). |
If you do this, please be very selective about which files to trigger on. |
@sanmai-NL if the Python extension is disabled for a workspace, it won't be activated at all at any point. This simply talks about when the Python extension is enabled globally, but users would like to have it activated automatically, without having to open a Python file or triggering a command. That said, we should definitely be mindful in which files to trigger it on. I've only ever used From the list of files mentioned, is there anything else you think would not be mostly related to Python? |
I say not being enabled or not being recommended rather than being disabled. |
I'd be thrilled if we could just get going with |
@luabud, @brettcannon, @karthiknadig, any thoughts on this for the short-term? @BrandonLWhite, has a PR up for just "pyproject.toml". If we're doing it for one we should at least do it for the following:
We could also do it for |
@ericsnowcurrently we can't do it on just As for whether we are ready to move forward with this, that's a call for @luabud . But starting with |
Agreed, though I'd add |
Hello, I was wondering if this new behavior was going to be controllable by a setting. It's quite desirable on its own, but as a workaround for microsoft/vscode-remote-release#1760, I've been trying to control when the Python extension gets loaded by closing any active Python files before I reload the VSCode window (for the cases when I need to reload VSCode) |
One thing to be aware of is we used to get complaints about being overly liberal with launching the extension by folks who happen to have Python scripts in their e.g. C++ code base who do nothing more than generate test data by running Python, and so they only edit Python code every couple of months and not every time they open a workspace. Without discussing it with the team 😉 , my guess is we can probably consider files that very clearly delineate that a project is primarily Python-based (e.g. So I think that would suggest we could consider:
We don't need |
I like that thought process :) The bit about R Anaconda projects is a good one, and it'll apply to I've seen a few data science projects just using Dockerfiles for dependency management, but the line probably has to be drawn somewhere before "parsing build scripts". Besides, those projects should at least be using |
This sounds amazing! Thank you for all your hard work folks :) |
Sounds great! I would also highly support the consideration of |
@luabud what do you think about my proposed list of files for triggering? |
I like it, I'd just add |
@luabud WFM! Would anyone hear like to open a pull request to add the following files as triggers for the extension?
|
Yup :) |
Thanks to @Soneji for the PR and everyone else in constructively participating in the discussion! This will be out in our March release. |
this is amazing. it was def my biggest UX painpoint of the vscode-python extension (and maybe of all of VSCode?!). This particularly will help users of dbt! |
@Soneji Could you also add a trigger for |
hey @lsorber I can send another PR (and so could you! 😉 ) but it's up to the team that maintains the project (@brettcannon , @luabud , etc.) whether they approve of it and ultimately whether it gets merged. |
Also, if we're increasing the list of files, we should definitely add the poetry files too (from the first comment), like |
@lsorber @Soneji we have actually been triggering for |
@brettcannon thanks for clarifying, that makes sense. Would it be possible to trigger activation based on their being a virtual/conda environment associated with the workspace? That should have pretty high recall and precision I expect. |
@lsorber only if there's a way to statically list a file to trigger against. All the details of what we can trigger on can be found at https://code.visualstudio.com/api/references/activation-events. We purposefully don't blindly trigger due to how big/heavy the extension is. |
Right, but VS Code knows whether there's a Python environment associated with the workspace, so that seems like it would be a perfect trigger, or not? |
@lsorber I like that idea if it's possible. I think all my python projects have |
@lsorber VS Code only "knows" that there's a Python environment because our extension makes that true. Technically VS Code itself couldn't care less about any of this; all it cares about is knowing when to launch our extension. We then bring in the concept of a Python environment after we start up. So this issue is specifically about when to launch our extension which itself brings in the concept of Python environments. |
@brettcannon I see, then how about a minimal startup to check whether there's a Python environment associated with the workspace and if not (and nothing else would trigger the extension) immediately shut down again? |
@lsorber that is still a very expensive thing to do (and especially for conda). |
Maybe this could be taken to the vscode repo itself and see if they can add another type of activation event? Is there any sort of (not very intensive) activation event that could work for conda, and could even be useful for other developers? |
@brettcannon why would that be expensive? I'm referring to simply checking whether the user associated a Python environment with the workspace in their workspace Making the presence of a workspace-specific setting a new type of trigger sounds like it could be a solution (based on my limited understanding of VS Code). |
We would still have to launch the extension to detect this. Plus not every user who sets up a Python environment wants to load the extension every time (e.g. C/C++ users who have some Python code to gather test data). The existence of settings is not enough information to infer that activation of the extension is desirable in all cases. Hence why we have only trigger automatic loading on project-level files instead of any Python file existing. Now if you're proposing a hypothetical check for a setting, then that's different, but not at all under our control as that would have to come from VS Code. Otherwise you can open a feature request at https://github.com/microsoft/vscode-python/discussions/categories/ideas and see if enough people can convince us to ignore non-Python conda users and thus trigger on |
Goal - Lets not wait for the user to open a python file to activate the extension
If the user has some of the following files we could probably activate the extension without having to wait for the user to open a python file:
__init__.py
src/__init__.py
tests/__init__.py
The text was updated successfully, but these errors were encountered: