Disable import sorting for virtualenv
See original GitHub issueEnvironment data
- VS Code version: 1.49.2
- Extension version (available under the Extensions sidebar): 2020.9.111407
- OS and version: macOS 10.15.6
- Type of virtual environment used: poetry
- Value of the
python.languageServer
setting: Pylance
Expected behaviour
isort shouldn’t run. Because the extension passes file contents via stdin, isort can’t know whether the file should be ignored: https://github.com/PyCQA/isort/issues/1500
More generally, it’s counterintuitive that 3rd party files are treated the same as project files. These files are sometimes viewed or edited to aid in debugging, but that shouldn’t trigger formatting, import sorting, etc.
Actual behaviour
isort is run.
Output pane:
> <...>/.venv/bin/isort - --diff
cwd: <...>/.venv/lib/python3.8/site-packages/<package>
Steps to reproduce:
- Open a file in the project’s virtualenv site-packages directory and save it.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:21
Top Results From Across the Web
Disable python import sorting in VSCode - Stack Overflow
I am trying to disable vscode from formatting my python imports when I save my file. I have some code that must run...
Read more >Configuration options for isort
To enable this, isort exposes a plethora of options to specify how you want your imports sorted, organized, and formatted. Too busy to...
Read more >reorder-python-imports - Visual Studio Marketplace
VSCode extension to sort and refactor python imports using reorder-python-imports . Unlike other import organizers, reorder-python-imports ...
Read more >Incorrect import sorting: Local libraries are treated as third-party
path and thus in the interpreter paths when we're indexing the configured SDK. As a workaround you can explicitly remove the corresponding entry...
Read more >Python layer - Spacemacs (develop)
If you want imports to be automatically sorted when you save a file (using isort), set the python-sort-imports-on-save variable in the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@elpablete Yep, it’s a bit odd… definitely a hack, but it works. Hopefully the authors of vscode-python will add a proper solution soon.
Thanks for the class. That true seemed weird to me so it is cool to actually learn what it means.