microsoft / vscode-isort

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

Docs: Using bundled isort or not? #341

Closed thernstig closed 8 months ago

thernstig commented 10 months ago

The README.md says:

The bundled isort is only used if there is no installed version of isort found in the selected python environment.

Then further down it says the default setting is:

isort.importStrategy useBundled

Setting to choose where to load isort from. useBundled picks isort bundled with the extension. fromEnvironment uses isort available in the environment.

Doesn't these contradict eachother? With all default settings, does it use the isort found in the environment, or the one bundled with the extension?

karthiknadig commented 10 months ago

With "isort.importStrategy" : "useBundled" (which is default) it uses the one shipped in the extension.

This description needs to be updated.

thernstig commented 10 months ago

So users who install an isort version themselves in a Python environment definitely should change it to fromEnvironment?

I think it would be great if it worked like auto-discovery as another option i.e. "auto" or "autoDiscover" where it selects the one from the environment if it exists, otherwise the bundled one.

karthiknadig commented 10 months ago

So users who install an isort version themselves in a Python environment definitely should change it to fromEnvironment?

Correct.

The fromEnvironment scenario should work in the way where it attempts to load isort from the environment, and uses isort shipped with the extension as fallback.

thernstig commented 10 months ago

@karthiknadig the VS Code Ruff extension prefers fromEnvironment first (and also falls back) which is much more intuitive. Especially since you fall back.

Otherwise all projects who have workspace settings need to change this config, which they most likely want if they also run isort in CI.

luabud commented 8 months ago

We made some changes to the README to clarify how the settings work and the default values: https://github.com/microsoft/vscode-isort/blob/main/README.md. I'm closing this issue as addressed but let us know if there's still more clarifications we can make there and I can reopen 😊

And if you want you can also file a new feature request for adding an "auto" value for importStrategy so we can gauge interest from the community!