Replies: 5 comments 3 replies
-
Pylance doesn't parse these at all; we rely on the Python extension to do this and just query them for the info. I don't think they support See: https://code.visualstudio.com/docs/python/environments#_environment-variable-definitions-file |
Beta Was this translation helpful? Give feedback.
-
Oh, that's literally the link you provided, oops. In any case, I think this should be transferred, since we can't fix this in Pylance, anyway. |
Beta Was this translation helpful? Give feedback.
-
This is just a workaround, but you could also write this temporarily:
IIRC this is functionally equivalent in the shells I'm familiar with. |
Beta Was this translation helpful? Give feedback.
-
The trick with this is there is no such thing as an "environment definition file standard". As such, we use a node project to do the parsing for us which apparently doesn't support |
Beta Was this translation helpful? Give feedback.
-
Moved to #17182 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I know VS Code with Pylance supports loading environment variables from a
.env
(dotenv file), which is great. It allows me to, for example, easily run or debug tests right from the editor, using all the environment variables needed.Here's the example from the docs:
Feature Request
I would like VS Code / Pylance to also support defining the variables with
export
, as in:This would allow me to use the same set of environment variables from the command line by sourcing that file.
For example I could load the environment:
$ source .env
And then run other commands that would use the same environment variables, for example, to run the tests using
coverage
:$ coverage run --source ./app/ -m pytest
Current behavior
As Currently VS Code / Pylance doesn't support having
export
in these.env
files, I have to manually add theexport
before each variable before using it on the command line, and then I have to manually remove thoseexport
s manually to run again the tests from inside VS Code.Apart from the double effort of adding and removing those
export
s, you can imagine that I often forget I had to do that, and I end up spending a long time debugging "why it's not working" in one place or the other, while it was just that I forgot to add or remove thoseexport
s. 😅Beta Was this translation helpful? Give feedback.
All reactions