Issue with new isort extension installed as from VS-Code Update October 2022 (version 1.73)

Question:

I’m using VS-Code version 1.73.1, with MS Python extension v2022.18.2, on Windows 10 Pro, Build 10.0.19045. After installing the October 2022 update of VS Code, when writing Python code I noticed nagging error diagnostics being issued by the isort extension about the import order of modules. Previously, I had never encountered such diagnostics.

I traced this behaviour back to the VS Code release notes for the Update October 2022. These announce the migration of VS Code to a new stand-alone isort extension, instead of the isort support built into the Python extension, by automatically installing it alongside the Python extension. When opening a file in which the imports do not follow isort standards, the extension is intended to issue an error diagnostic and display a Code Action to fix the import order.

Whilst the extension seems to work as intended, I found the issues described below:

1. Even after having executed the Code Action to fix the import order, a ‘light-bulb’ with the same error diagnostic and Code Action again pops up on moving the cursor to a new line of code.

2. The error diagnostic and Code Action ‘light-bulb’ are also displayed when moving the cursor to any new line of code, even when all lines of code in the file have been commented out; that is, effectively, there are no longer any import statements in the code, and therefore also nothing to be sorted.

I’d appreciate comments on whether this is a recognised issue in VS Code, and if so, whether any workarounds are available. It defeats the purpose of having an ‘error lightbulb’ pop up on every line of code, just to find a code action recommending to fix the import order, even when this requires no fixing.

I have opened this question on this forum as recommended on the GitHub ‘Contributing to VS Code’ page.

Asked By: Gunter Seydack

||

Answers:

Upgrade the isort extension version to latest(v2022.8.0).

enter image description here

Answered By: JialeDu

It may be due to the deprecated version of Python.

In my case, I change the default Python interpreter for isort.

Go to settings -> search python.

There’s a menu where you can determine the interpreter of isort

My default version was 3.6, which caused an error.

I switched to 3.8, and the problem resolved

enter image description here

Answered By: WhaSukGO
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.