microsoft / vscode-isort

Import sorting for python using the isort library.
https://marketplace.visualstudio.com/items?itemName=ms-python.isort
MIT License
91 stars 22 forks source link

Isort ignores headings #306

Closed mgorfer closed 1 year ago

mgorfer commented 1 year ago

Using the VSCcode isort extension, the custom headings which I defined in my isort.cfg in the root of my repository are ignored. The known_first_party modules from that file are recognized though and everything is moved to the correct section (without headings). Using isort in the terminal, the correct headings as defined in my isort.cfg are applied.

When specifying this file in the isort.args using ["--settings-file", "xyz/.isort.cfg"] in my VSCode settings.json, the headings are applied.

My isort.cfg:

[settings]
default_section=THIRDPARTY
known_first_party=module_a, module_b
import_heading_future=Future
import_heading_stdlib=Standard Library
import_heading_thirdparty=Third party
import_heading_firstparty=First party
import_heading_localfolder=Local imports
lines_between_types=1
profile=black
karthiknadig commented 1 year ago

@mgorfer This is a bug in isort itself. See https://github.com/PyCQA/isort/issues/1989

Unfortunately, they have not released it yet (see https://github.com/PyCQA/isort/blob/main/CHANGELOG.md).

The workaround is to specify the config file manually.

Duplicate of https://github.com/microsoft/vscode-isort/issues/53