Skip to content

Remove code lenses for "set as interpreter" #3854

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

Closed
AlJohri opened this issue Jan 3, 2019 · 20 comments · Fixed by #19853
Closed

Remove code lenses for "set as interpreter" #3854

AlJohri opened this issue Jan 3, 2019 · 20 comments · Fixed by #19853
Assignees
Labels
area-environments Features relating to handling interpreter environments feature-request Request for new features or functionality good first issue needs PR Ready to be worked on

Comments

@AlJohri
Copy link

AlJohri commented Jan 3, 2019

#736

I don't know if you have usage statistics on this but it seems more annoying than useful. I am almost always working within a virtualenv which I set by clicking on the bottom left and selecting my python interpreter.

The hashbang by design is super generic, like #!/usr/bin/env python3. Clicking "set as interpreter" just changes it to system python which is almost always not useful, especially when you're already in a virtualenv.

I recommend removing this suggestion all together or at the very least removing it when the python path is explicitly listed in settings.json

screenshot_1_3_19__1_12_pm

@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Jan 3, 2019
@d3r3kk d3r3kk added feature-request Request for new features or functionality needs decision labels Jan 3, 2019
@ghost ghost removed triage-needed Needs assignment to the proper sub-team labels Jan 3, 2019
@gimbo
Copy link

gimbo commented Feb 13, 2019

Agreed; or at least there should be a way to hide this hint via settings.json. Right now the hint permanently wastes vertical real estate and the only way to get rid of it (AFAICS, and assuming this comment is still true) is to delete the shebang line.

@ablakey
Copy link

ablakey commented Apr 4, 2019

This is probably overkill but it may help some people.

This notification is powered by Code Lens. If you set "editor.codeLens": false, in your custom settings, it goes away. Note this also kills some other features, none of which I seem to be using for Python, but you might be! Here's a brief overview of what kinds of features are powered by it: https://code.visualstudio.com/blogs/2017/02/12/code-lens-roundup

@AlJohri
Copy link
Author

AlJohri commented Apr 4, 2019

I seem to use CodeLens quite a bit from your link.

I'd advocate for removing it once the python has been explicitly set by user action.

@gramster gramster added area-environments Features relating to handling interpreter environments and removed area-environments Features relating to handling interpreter environments feature-interpreter labels Oct 10, 2019
@brettcannon brettcannon changed the title disable permanent hint to change interpreter based on hashbang based on python disable permanent hint to change interpreter based on shebang Dec 11, 2019
@silkfire
Copy link

Any update on this?

@tgotwig
Copy link

tgotwig commented Jul 6, 2020

How to reproduce? 🤔

@brettcannon
Copy link
Member

We are going through old issues and we noticed that no one from the team had replied to this issue. I want to apologize for the oversight and to let you know that the issue was reviewed by the team and triaged (as shown by the labels applied to this issue).

@leoblum

This comment has been minimized.

@francois-rozet
Copy link

francois-rozet commented Mar 19, 2021

Hello, I too find this very annoying. Not to mention that the hint moves up and down as I type...

I think this could be very easily solved by adding something like

if (this.workspace.getInterpreter() !== undefined) {
    return [];
}

at

private async createShebangCodeLens(document: TextDocument) {

Unfortunately, I am not familiar with this extension, so I don't know how to workspace.getInterpreter() in practice.


I've looked into it a bit more, and it seems that we could use the public _pythonPathSetting variable of the InterpreterService as condition. Something like,

if (this.interpreterService._pythonPathSetting === '') {
    return [];
}

However, I don't think ShebangCodeLensProvider has access to interpreterService currently (?). Maybe does it require to add

@inject(IInterpreterService) interpreterService: IInterpreterService

in the constructor.

@brettcannon do you have any tip about this ?

@brettcannon
Copy link
Member

@francois-rozet That leading underscore means you shouldn't be poking around at it. 😄

@luabud is the "needs PR" for dropping the feature or for making it disappear when the environment has been chosen?

@francois-rozet
Copy link

francois-rozet commented Mar 19, 2021

@francois-rozet That leading underscore means you shouldn't be poking around at it. 😄

Oh my bad. Then adding a getter to that variable (getPythonPathSetting) or a property/method like isInterpreterSet (returning a boolean) could do the trick.

@luabud
Copy link
Member

luabud commented Mar 20, 2021

@brettcannon I believe we originally have agreed to hide it once the interpreter is set. I think we should open a discussion about removing this feature though 🤔

@zhongxiang117
Copy link

As an addition, I too feel it a little bit annoying, any updates on it?

I would like to add more info on it, my VSCode & Python-extension Version:

VSCode Version:
Version: 1.55.0 (user setup)
Commit: c185983a683d14c396952dd432459097bc7f757f
Date: 2021-03-30T16:01:55.261Z
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Windows_NT x64 10.0.18363
Python-extension version: v2021.3.680753044

As you can see, my OS is windows, after thoroughly read this #736, I found the problem is caused by using Shebang.

If I remove Shebang line, the info will be gone. However, I do want to keep this code interpreter hint line.

@brettcannon
Copy link
Member

@zhongxiang117 no updates as no one has participated in any discussion. 😄

@zhongxiang117
Copy link

@brettcannon , that is sad, but the issue is still open. Hope you can soon or happen to fix them..

@brettcannon
Copy link
Member

@zhongxiang117 to be clear, when I say "no one has participated in any discussion" I mean in this issue, not our team so we are currently not the hold-up on this. IOW no one has said whether they think full removal is better than simply hiding the lens if the interpreter has been set.

@francois-rozet
Copy link

@brettcannon I don't think the feature is very useful in itself, so it could be completely removed. Otherwise, hiding is fine and I think it can be implemented very fast as I mentioned above (#3854 (comment)).

@msftwindowslinux
Copy link

+1 that this is a largely useless feature worth dropping (commenting instead of thumbs-upping in hopes this moves the needle on "sufficient discussion")

@karrtikr
Copy link

karrtikr commented Sep 1, 2021

Hi everyone 👋

You can add the following to your User settings as a workaround:

    "[python]": {
        "editor.codeLens": false,
    }

Search for Open settings (json) in the command palette to open the settings file. We plan to change this to a lightbulb fix suggestion instead so it's not as distracting.

@karrtikr karrtikr changed the title disable permanent hint to change interpreter based on shebang Do not use code lenses for permanent hint to change interpreter based on shebang Sep 1, 2021
@github-actions github-actions bot removed the needs PR label Aug 9, 2022
@karrtikr karrtikr added the needs PR Ready to be worked on label Aug 9, 2022
@luabud luabud changed the title Do not use code lenses for permanent hint to change interpreter based on shebang Remove code lenses for "set as interpreter" Aug 24, 2022
@luabud
Copy link
Member

luabud commented Sep 16, 2022

@ChinazoOnwukaike
Copy link

Assign this to me please.

karrtikr pushed a commit that referenced this issue Sep 16, 2022
Closes #3854

Removed shebangCodeLensProvider and IShebangCodeLensProvider as well as
their references and instances. Also removed the setShebangInterpreter.
eleanorjboyd pushed a commit to eleanorjboyd/vscode-python that referenced this issue Oct 4, 2022
Closes microsoft#3854

Removed shebangCodeLensProvider and IShebangCodeLensProvider as well as
their references and instances. Also removed the setShebangInterpreter.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 17, 2022
wesm pushed a commit to posit-dev/positron that referenced this issue Mar 28, 2024
…19853)

Closes microsoft/vscode-python#3854

Removed shebangCodeLensProvider and IShebangCodeLensProvider as well as
their references and instances. Also removed the setShebangInterpreter.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-environments Features relating to handling interpreter environments feature-request Request for new features or functionality good first issue needs PR Ready to be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.