Skip to content
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

Add VIRTUENV_BIN to the list of supported predefined variables to resolve linter settings #92

Open
jnoortheen opened this issue Jun 30, 2020 · 11 comments
Labels
feature-request Request for new features or functionality needs community feedback

Comments

@jnoortheen
Copy link

I am using flakehell as the runner for flake8 . I am able to configure it using

"python.linting.flake8Path": "~/.local/share/virtualenvs/proj/bin/flake8helled",

But I had to give the full path. It would be nice to have this variable to the list of predefined-variables. So it will work with different venvs and no need to change it every time.

So the above setting can be simplified like

"python.linting.flake8Path": "${VIRTUENV_BIN}/flake8helled",
@jnoortheen jnoortheen added triage-needed feature-request Request for new features or functionality labels Jun 30, 2020
@karthiknadig karthiknadig self-assigned this Jul 1, 2020
@karthiknadig
Copy link
Member

@jnoortheen Can you try "python.linting.flake8Path": "${env:VIRTUENV_BIN}/flake8helled", ? Notice the "env" prefix. Let me know if that works.

@karthiknadig karthiknadig added the info-needed Issue requires more information from poster label Jul 7, 2020
@jnoortheen
Copy link
Author

@jnoortheen Can you try "python.linting.flake8Path": "${env:VIRTUENV_BIN}/flake8helled", ? Notice the "env" prefix. Let me know if that works.

Yes it is working if I launch it from terminal after setting the environment variable. But it would be nice to have a variable pointing to the current venv path selected from the Python extension automatically.

@DylanYoung
Copy link

DylanYoung commented Jul 10, 2020

That is a bit odd. Does vscode-python special-case the name "flake8" or something? Shouldn't it just look it up on the path regardless... I think I encountered a similar issue trying to configure darker for black. I didn't necessarily want it to look in the venv in that case (black only runs on Py3), but I did want it to look in the PATH, lol.

@jnoortheen
Copy link
Author

@karthiknadig Do you need any other info?

@karthiknadig
Copy link
Member

@jnoortheen We have all the information we need. We have marked this issue as "needs decision" to make sure we have a conversation about your idea. We plan to leave this feature request open for at least a month to see how many 👍 votes the opening comment gets to help us make our decision.

@DylanYoung Can you file a separate bug for the issue?

@karrtikr Does ${command:python.interpreterPath} work in this scenario? I don't remember if settings resolves command.

@karthiknadig karthiknadig removed the info-needed Issue requires more information from poster label Jul 11, 2020
@karrtikr
Copy link
Contributor

karrtikr commented Jul 13, 2020

Unfortunately no, command variables are only supported for launch.json and tasks.json file. See this.

VSCode doesn't automatically resolve command variables when we fetch settings using API, and probably can't as launching commands is an async operation but fetching settings is not. (Opened feature request microsoft/vscode#102414 to confirm)

@DylanYoung
Copy link

It's not a separate issue, lol. It just doesn't look in PATH, same as this issue (since VENV should be in PATH).

@karthiknadig
Copy link
Member

@DylanYoung There are two things. 1) Accessing a relative location based on the selected interpreter. 2) Running tools in an activated environment. In your case we should be running flake8 from an activated environment. We should not be searching PATH for flake8. Calling flake8 should run the the binary/script they have under /scripts directory. The fact that we are not running from linter from an activated environment is a separate issue.

@luabud luabud assigned luabud and unassigned karthiknadig Aug 12, 2020
@codekoriko
Copy link

codekoriko commented Apr 5, 2021

any update on this?

with settings:
"python.linting.flake8Path": "flake8helled"

and with environment activated and the binary present in /scripts director, vscode complains saying flake8 is not installed.

@DylanYoung
Copy link

DylanYoung commented Apr 5, 2021

I have to disagree, though perhaps I'm missing something about the design. If you're skipping my path, then you don't integrate with my dev environment. I have tools that aren't part of my virtualenv that i need to access in my projects.

I think you misunderstand as well. Flake 8 (darker/black) isn't in my virtualenv. It's on my PATH.

In any case, my only point is that fixing the PATH resolution, fixes a lot of related issues. No one should have to be explicitly selecting their virtualenv to run a tool, as the venv should be the first location in PATH. The feature request here is an X Y problem.

@karrtikr
Copy link
Contributor

karrtikr commented Dec 15, 2022

add VIRTUENV_BIN to the list of supported predefined variables

The premise of this issue states we support a list of predefined variables already, can you name a few we support? I could not find any. Supporting this scenario would require us to resolve VIRTUENV_BIN differently for each different workspace folder in workspace, as each folder can have its own virtual env.

Now that we've our own flake8 extension moving this over to https://github.com/microsoft/vscode-flake8 as this will needed to be supported there. Checkout the settings for that extension.

@karrtikr karrtikr changed the title add VIRTUENV_BIN to the list of supported predefined variables Add VIRTUENV_BIN to the list of supported predefined variables to resolve linter settings Dec 15, 2022
@karrtikr karrtikr removed the feature-request Request for new features or functionality label Dec 15, 2022
@karrtikr karrtikr transferred this issue from microsoft/vscode-python Dec 15, 2022
@karthiknadig karthiknadig added feature-request Request for new features or functionality needs community feedback and removed triage-needed labels Jan 19, 2023
@karthiknadig karthiknadig removed their assignment Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality needs community feedback
Projects
None yet
Development

No branches or pull requests

6 participants