Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
NewUserHa opened this issue Feb 19, 2023 · 2 comments
Open

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

NewUserHa opened this issue Feb 19, 2023 · 2 comments
Labels
bug Issue identified by VS Code Team member as probable bug needs investigation

Comments

@NewUserHa
Copy link

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.

@github-actions github-actions bot added the triage-needed Issue is not triaged. label Feb 19, 2023
@karthiknadig karthiknadig self-assigned this Feb 21, 2023
@karthiknadig
Copy link
Member

Currently we use this check as a workaround to detect python code vs other code in cells. Cells appear like individual documents to isort server currently. This is because the underlying package pygls has not yet fully implemented .ipynb support. Once that is done, we will no longer need to have this this workaround. Until then this is a limitation.

@karthiknadig karthiknadig added bug Issue identified by VS Code Team member as probable bug needs investigation and removed triage-needed Issue is not triaged. labels Feb 23, 2023
@karthiknadig karthiknadig removed their assignment Feb 23, 2023
@qisoster
Copy link

I'm getting a somewhat similar error:

2023-07-28 15:05:33.187 [info] [Trace - 3:05:33 PM] Received notification 'window/logMessage'.
2023-07-28 15:05:33.187 [info] [Error - 3:05:33 PM] Syntax error in code: Traceback (most recent call last):
  File "c:\Users\***\.vscode\extensions\ms-python.isort-2023.10.1\bundled\tool\lsp_server.py", line 293, in is_python
    ast.parse(code)
  File "D:\devel\sdk\python311\Lib\ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<unknown>", line 104
    .......
       ^^^
SyntaxError: invalid syntax

2023-07-28 15:05:33.188 [info] [Trace - 3:05:33 PM] Received notification 'window/showMessage'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug needs investigation
Projects
None yet
Development

No branches or pull requests

3 participants