Skip to content

"no organize imports action available" error on uncompleted code #243

@NewUserHa

Description

@NewUserHa

report "no organize imports action available" error in the editor area, but
isort output:

[Error - 9:02:40 AM] Syntax error in code: Traceback (most recent call last):
  File "c:\Users\User\.vscode\extensions\ms-python.isort-2022.8.0\bundled\tool\server.py", line 291, in is_python
    ast.parse(code)
  File "c:\Program Files\Python311\Lib\ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<unknown>", line 78
    if r != '':
IndentationError: unexpected indent

[Warn  - 9:02:40 AM] Skipping non python code: c:\test.py
[Error - 9:02:40 AM] Request textDocument/codeAction failed.
  Message: AttributeError: 'NoneType' object has no attribute 'stdout'
  Code: -32602 

isort should only process the import ... part since it will not move the imports in methods to the head of the file anyway,
or isort should report the error correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable bugneeds investigation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions