microsoft / vscode-isort

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

Imports are incorrectly sorted and/or formatted.isort(E) #237

Closed Phatlynx closed 1 year ago

Phatlynx commented 1 year ago

Error

image

image

If I add a space the issue is fixed, who decided import statements needs to separate?

image

karthiknadig commented 1 year ago

This is the isort tool which handles import sorting. The default is to separate python standard libraries and any user libraries. This extension does not make that decision, this extension shows what is reported by isort in the UI.

Repo for the tool itself: https://github.com/PyCQA/isort Settings you can use for the tool: https://pycqa.github.io/isort/docs/configuration/options.html The setting you are looking for is "Lines Between Sections"

Phatlynx commented 1 year ago

Thanks! I've disabled the extension altogether as I mainly use python for quick prototyping, therefore I don't have a need for isort. I can see where this would be useful when there's tens if not hundreds of import statements.

It shouldn't be On by default though, having to learn how to config yet another extension is just cumbersome, could I suggest putting these config options inside of Settings (not the json, but the Settings UI with checkboxes)

karthiknadig commented 1 year ago

@Phatlynx The check setting is off by default: image

It is in the UI: image

Make sure that you have the latest version of the extension. As for the specific settings for isort the tool those are configured using whatever mechanism the tool supports.