Organize imports conflicts with Black formatting
See original GitHub issueEnvironment data
- VS Code version:
1.37.0
- Extension version (available under the Extensions sidebar):
2019.8.29288
- OS and version:
Windows 10 Enterprise, 10.0.17763 Build 17763
- Python version:
3.7.4
- Type of virtual environment used:
Poetry/venv
- Relevant/affected Python packages and their versions:
black: 19.3-beta.0
- Jedi or Language Server:
Language server
Expected behaviour
Saving a file should not toggle between black-formatted and isort-formatted.
Actual behaviour
Saving a file once results in black-formatted, then saving it again results in isort-formatted, saving that results in black-formatted, and so on.
Steps to reproduce:
- Have Black installed
- Set config options as such:
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
}
- Create a python file with the following contents:
from something import (
aaaaa,
bbbbb,
ccccc,
ddddd,
eeeee,
fffff,
ggggg,
hhhhh,
iiiii,
jjjjj,
kkkkk,
)
- Save the file multiple times and watch it dance
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Python & VS Code: make Black and organize imports work ...
I use Black to format my Python code, and I tell VS Code to organise imports on save. Here's the relevant bit of...
Read more >Using Black with other tools - Black 22.12.0 documentation
Some of them need a bit of tweaking to resolve the conflicts. Listed below are Black ... isort helps to sort and format...
Read more >Imports are incorrectly sorted and/or formatted | VS Code
My guess is your linter is complaining about unused imports. Hover over the red underscored word and see what the message is. –...
Read more >Making isort compatible with black - A code to remember
Both isort and black are a must have in my python life, but with their default settings, I will get different imports formats....
Read more >How to automate Python code formatting | by AlexV - Medium
pipenv run pip install black. Below I have created a file that I would like to format: import os, sysfrom file_to_be_imported import ......
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
I had this issue but updated the
isort
args in vscode settings to match those consistent with black, and that stopped the flickering (but not ideal - ideally it would use those insetup.cfg
)Closing in favour of https://github.com/microsoft/vscode/issues/83586.