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

Error when saving an empty file. #157

Closed LoyalBlanc closed 1 year ago

LoyalBlanc commented 1 year ago

When I want to save an empty file:

Saving 'draft.py': Getting code actions from ''Python', 'IntelliCode API Usage Examples', 'Jupyter', 'isort'' configure.

And I must restart VS Code after the 'Cancel'

My setting is like:

    "[python]": {
        "editor.formatOnSave": true,
        "editor.formatOnPaste": true,
        "editor.codeActionsOnSave": {
            "source.fixAll.eslint": true,
            "source.organizeImports": true
        },
    },
    "isort.args": [
        "--profile",
        "black"
    ],
karrtikr commented 1 year ago

Saving 'draft.py': Getting code actions from ''Python', 'IntelliCode API Usage Examples', 'Jupyter', 'isort'' configure.

Can you try disabling these extensions one by one to see which one is causing the problem?

LoyalBlanc commented 1 year ago

Yes, I mean when I remove the line "source.organizeImports": true, everything is fine

In fact, except saving an empty file or a file with only blank line, no error will be raised.

karrtikr commented 1 year ago

I understand that, however I am not sure isort is the culprit given the logs. Please disable/uninstall each extension and see which extension is causing the issue.

karthiknadig commented 1 year ago

@LoyalBlanc as @karrtikr mentioned, the above error means all 4 of those language servers participate in providing code actions. Can you look at Output > isort panel, and see if there are any clues. You can also enable verbose logging by setting isort.logLevel to debug.

karthiknadig commented 1 year ago

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on then we will be happy to re-open this issue to pick up where we left off.