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

python.envFile setting looks to be ignored #154

Open
rganczarek opened this issue Sep 18, 2023 · 2 comments
Open

python.envFile setting looks to be ignored #154

rganczarek opened this issue Sep 18, 2023 · 2 comments
Assignees

Comments

@rganczarek
Copy link

Hello, I'm having a problem coniguring mypy plugin to work with my project.

I'm having this error in the mypy shell:

  File "/path/to/project/src/myproject/config.py", line 123, in <module>
    API_ID = int(os.getenv('API_ID'))
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

This is because I have a project with settings configured by env variables.

My directory settings:

{
  "python.envFile": "${workspaceFolder}/.env.test",
  "mypy-type-checker.args": [
    "--config-file=${workspaceFolder}/src/pyproject.toml"
  ],
  "mypy-type-checker.interpreter": [
    "/home/rganczarek/.virtualenvs/myproject/bin/python"
  ]
}

where .env.test contains:

API_ID=0

Tried switching to "mypy-type-checker.path", but it didn't help.

Temporary workaround:

Create file venvrun.sh:

#!/usr/bin/env bash

source ~/.virtualenvs/$1/bin/activate
set -a
. /path/to/project/.env.test
set +a
$2 ${@:3}

and in settings.json do:

"mypy-type-checker.path": [
    "/path/to/venvrun/venvrun.sh",
    "myproject_venv",
    "mypy"
  ],
@karthiknadig
Copy link
Member

We need to use pythonExtension.environments.getEnvironmentVariables API to get the full set of environment variables and send the diff to the server, per-workspace.

@mayrholu
Copy link

Any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants