microsoft / microsoft/vscode-isort

Incorrect pyright comment movement

Open
#712 4 comments 0 reactions 0 assignees View on GitHub
bug triage-needed
Dominant language
Python
Stars
106
Forks
29
Avg merge
1d 23h
Merged PRs (30d)
12

Description

## Diagnostic Data
- Python version (& distribution if applicable, e.g., Anaconda): Python 3.13.12
- Type of virtual environment used (e.g., conda, venv, virtualenv, etc.): venv
- Operating system (and version): Windows-10-10.0.19045-SP0 64 Bits
- Version of tool extension you are using: 2026.6.0

## Behaviour
### Expected Behavior
The imports should be organized in a way that respects the # pyright: ignore comments

### Actual Behavior
The file content is changed to

```py
from bpy.props import \
BoolProperty # pyright: ignore[reportUnknownVariableType]
from bpy.props import \
EnumProperty # pyright: ignore[reportUnknownVariableType]
from bpy.props import \
StringProperty # pyright: ignore[reportMissingModuleSource]; pyright: ignore[reportUnknownVariableType]

```

## Reproduction Steps:
Create a new file with the following content, and have it end in .py

```py
from bpy.props import ( # pyright: ignore[reportMissingModuleSource]
BoolProperty, # pyright: ignore[reportUnknownVariableType]
EnumProperty, # pyright: ignore[reportUnknownVariableType]
StringProperty, # pyright: ignore[reportUnknownVariableType]
)
```

Run Organize Imports from the command palette

Image

## Logs:
```

2026-08-13 14:44:42.156 [info] [Trace - 2:44:42 PM] Sending request 'textDocument/codeAction - (79)'.
2026-08-13 14:44:42.156 [info] Params: {
"textDocument": {
"uri": "file:///FILEPATH/isort_issue_1.py"
},
"range": {
"start": {
"line": 5,
"character": 1
},
"end": {
"line": 5,
"character": 1
}
},
"context": {
"diagnostics": [],
"only": [
"source.organizeImports"
],
"triggerKind": 1
}
}

2026-08-13 14:44:42.160 [info] [Trace - 2:44:42 PM] Received notification 'window/logMessage'.
2026-08-13 14:44:42.160 [info] Params: {
"type": 4,
"message": "PROJECTPATH\\.venv\\Scripts\\python.exe -m isort - --filename PROJECTPATH\\experiments\\terminal\\bug_reports\\isort\\isort_issue_1.py"
}

2026-08-13 14:44:42.160 [info] PROJECTPATH\.venv\Scripts\python.exe -m isort - --filename PROJECTPATH\experiments\terminal\bug_reports\isort\isort_issue_1.py
2026-08-13 14:44:42.161 [info] [Trace - 2:44:42 PM] Received notification 'window/logMessage'.
2026-08-13 14:44:42.161 [info] Params: {
"type": 4,
"message": "CWD Linter: PROJECTPATH"
}

2026-08-13 14:44:42.161 [info] CWD Linter: PROJECTPATH
2026-08-13 14:44:42.170 [info] [Trace - 2:44:42 PM] Received notification 'textDocument/publishDiagnostics'.
2026-08-13 14:44:42.170 [info] Params: {
"uri": "file:///FILEPATH/isort_issue_1.py",
"diagnostics": []
}

2026-08-13 14:44:42.171 [info] [Trace - 2:44:42 PM] Received response 'textDocument/codeAction - (79)' in 15ms.
2026-08-13 14:44:42.171 [info] Result: [
{
"title": "isort: Organize Imports",
"kind": "source.organizeImports",
"diagnostics": [],
"edit": {
"documentChanges": [
{
"textDocument": {
"uri": "file:///FILEPATH/isort_issue_1.py",
"version": 31
},
"edits": [
{
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 6,
"character": 0
}
},
"newText": "\r\nfrom bpy.props import \\\r\n BoolProperty # pyright: ignore[reportUnknownVariableType]\r\nfrom bpy.props import \\\r\n EnumProperty # pyright: ignore[reportUnknownVariableType]\r\nfrom bpy.props import \\\r\n StringProperty # pyright: ignore[reportMissingModuleSource]; pyright: ignore[reportUnknownVariableType]\r\n"
}
]
}
]
},
"data": "file:///FILEPATH/isort_issue_1.py"
}
]

2026-08-13 14:44:42.188 [info] [Trace - 2:44:42 PM] Sending notification 'textDocument/didChange'.
2026-08-13 14:44:42.188 [info] Params: {
"textDocument": {
"uri": "file:///FILEPATH/isort_issue_1.py",
"version": 32
},
"contentChanges": [
{
"range": {
"start": {
"line": 5,
"character": 0
},
"end": {
"line": 5,
"character": 1
}
},
"rangeLength": 1,
"text": ""
},
{
"range": {
"start": {
"line": 4,
"character": 45
},
"end": {
"line": 4,
"character": 45
}
},
"rangeLength": 0,
"text": "MissingModuleSource]; pyright: ignore[report"
},
{
"range": {
"start": {
"line": 4,
"character": 18
},
"end": {
"line": 4,
"character": 19
}
},
"rangeLength": 1,
"text": ""
},
{
"range": {
"start": {
"line": 4,
"character": 4
},
"end": {
"line": 4,
"character": 4
}
},
"rangeLength": 0,
"text": " "
},
{
"range": {
"start": {
"line": 4,
"character": 3
},
"end": {
"line": 4,
"character": 3
}
},
"rangeLength": 0,
"text": "\\\r\n"
},
{
"range": {
"start": {
"line": 4,
"character": 2
},
"end": {
"line": 4,
"character": 2
}
},
"rangeLength": 0,
"text": "import"
},
{
"range": {
"start": {
"line": 4,
"character": 1
},
"end": {
"line": 4,
"character": 1
}
},
"rangeLength": 0,
"text": "bpy.props"
},
{
"range": {
"start": {
"line": 4,
"character": 0
},
"end": {
"line": 4,
"character": 0
}
},
"rangeLength": 0,
"text": "from"
},
{
"range": {
"start": {
"line": 3,
"character": 16
},
"end": {
"line": 3,
"character": 17
}
},
"rangeLength": 1,
"text": ""
},
{
"range": {
"start": {
"line": 2,
"character": 63
},
"end": {
"line": 2,
"character": 63
}
},
"rangeLength": 0,
"text": "\r\nfrom bpy.props import \\"
},
{
"range": {
"start": {
"line": 2,
"character": 16
},
"end": {
"line": 2,
"character": 17
}
},
"rangeLength": 1,
"text": ""
},
{
"range": {
"start": {
"line": 1,
"character": 22
},
"end": {
"line": 1,
"character": 69
}
},
"rangeLength": 47,
"text": "\\"
}
]
}
```

## Outcome When Attempting Debugging Steps:

Did running it from the command line work? Yes

## Extra Details

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the provided bpy.props example, first running the logged `python -m isort - --filename ...` command directly and then through Organize Imports. Trace how isort handles inline `# pyright: ignore` comments when splitting imports; done means the imports remain valid and each ignore comment stays attached to the intended import or name.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.