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

Turning off `isort.check` has no effect #173

Closed alexreg closed 1 year ago

alexreg commented 1 year ago

Setting "isort.check": false in my config file has no effect; isort is still always run. Is this a known bug?

brettcannon commented 1 year ago

Do you have any isort settings under the python namespace from the Python extension or generic import sorting code action settings? Specifically, there is no known bug about this, but we have had some folks with stale settings from the Python extension that they didn't realize they had which this extension also reads.

alexreg commented 1 year ago

@brettcannon Hmm, I don't seem to have any other isort settings, and my only Python ones are the following.

    "python.defaultInterpreterPath": "/opt/homebrew/bin/python3",
    "python.analysis.extraPaths": [
        "/opt/homebrew/opt/pyinvoke/libexec/lib/python3.10/site-packages/",
    ],
    "python.formatting.provider": "black",
    "python.languageServer": "Pylance",

I also have an .isort.cfg file in my home directory, but I wouldn't imagine that should affect anything.

brettcannon commented 1 year ago

Is it running and reporting something, or is this report more about the simple fact that the extension loads?

alexreg commented 1 year ago

@brettcannon Apologies. This may be something done by the MS Python extension actually, although it evidently uses isort configuration to some extent. I should have been explicit I was dealing with isort running on save. The following setting seems to disable it.

    "[python]": {
        "editor.codeActionsOnSave": {
            "source.organizeImports": false,
        },
    }

isort.check doesn't impact this setting (perhaps by design), though isort.path does.

brettcannon commented 1 year ago

isort.check doesn't impact this setting (perhaps by design), though isort.path does.

Correct, they mean different things. isort.check will check if your imports are sorted or not, while the source.organizeImports is whether VS Code triggers the extension to automatically sort your extensions. And regardless of either, the extension will be loaded if you have it enabled and open a Python file.

So I think we figured out what is going on, so I'm closing this issue. If I'm wrong about that then please feel free to open the issue again.

alexreg commented 1 year ago

@brettcannon Makes sense. Thanks for the clarification, and sorry again for the bother.