Mirror question to:
I want to configure how VSCode is invoking isort, so I can customize when calling Organize imports
in a .py file.
In particular, VSCode has started removing a blank line between two isort-sections, don't know why.
from django...
from myproject... # removing blanck line between 2 sections
You can make isort
compatible with black
and enjoy a formatted code upon saving your document. Here are two ways to achieve this:
Black
and Isort
’s settings on pyproject.toml
.
Inside your root’s project folder, create/update your pyproject.toml
file:[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
line_length = 88
profile = "black"
settings.json
and configure Black
and Isort
.{
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"python.formatting.provider": "black",
"isort.args": ["--profile", "black"],
}
source.organizeImports: true
runs Isort automatically upon saving your document.
As of version 1.85, you want to set "source.organizeImports": "explicit"
to get the same functionality as the old "true"
, per the docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With