vscode-python: (Black) Formatter & Pytest fail with .env in Python
Environment data
VSCode: Most recent non-insider version. Python: 3.7 Black: Most recent.
Expected behaviour
Black is registered as a formatter. Code is formatted.
Actual behaviour
Nothing happens.
Steps to reproduce:
Working:
- Register black as the formatter of choice.
- Create a directory with the following structure:
root
- project
- file_to_be_formatted.py
- Add some code into
file_to_be_formatted.pythat has formatting issues. - Run black with
alt + shift + f. It formats the code!
Failing:
- Register black as the formatter of choice.
- Create a directory with the following structure:
root
- .env (This contains "PYTHONPATH=./project" to make properly configure package detection, etc.)
- project
- file_to_be_formatted.py
- Add some code into
file_to_be_formatted.pythat has formatting issues. - Run black with
alt + shift + f. It does not format the code
So having a .env file will silently make black fail. Running black from the command line on file_to_be_formatted.py does still work
I follow this: https://github.com/microsoft/python-language-server/blob/master/TROUBLESHOOTING.md#unresolved-import-warnings
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16
I upvoted all of the above. I’ll restructured my project to
.envand no additional settings insettings.json.jedi disabled.With this setup VSCode:
Testtabpip install -e .from the project root