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

autosave afterDelay cannot trigger code actions, e.g. import resorting #203050

Closed
zhang-stephen opened this issue Jan 21, 2024 · 6 comments
Closed
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s)

Comments

@zhang-stephen
Copy link

zhang-stephen commented Jan 21, 2024

Type: Bug

Behaviour

Expected vs. Actual

the code action should be triggered after auto saving, but it was not triggered. it could be reproduced w/wo remote environment.

the code action would be triggered if I save the file explicitly, e.g. Ctrl+S pressed.

Steps to reproduce:

  1. install extensions: ms-python.python, ms-python.isort, ms-python.black-formatter, ms-python.vscode-pylance
  2. vscode settings for reproducing:
{
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": "always"
        },
    },
    "isort.args": [
        "--profile",
        "black"
    ],
    "file.autosave": "afterDelay",
}
  1. new a pyproject.toml in a folder
[tool.black]
line-length = 120

[tool.isort]
profile = "black"
  1. and new a python source file in this folder:
import logging
import argparse
import socket
import re
import math
  1. waiting for the auto-saving, and the code action on saving source.organizeImports not triggered, the imports are not sorted.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.7
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
  • Value of the python.languageServer setting: Pylance
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2024-01-22 04:42:33.992 [info] Default formatter is set to ms-python.black-formatter for workspace /Users/stephen/Works/repos/xSystemEm
2024-01-22 04:42:33.992 [info] Test server listening.
2024-01-22 04:42:33.995 [info] > conda info --json
2024-01-22 04:42:34.401 [info] > /opt/homebrew/Caskroom/miniforge/base/bin/python -I ~/.vscode-server/extensions/ms-python.python-2023.22.1/pythonFiles/get_output_via_markers.py ~/.vscode-server/extensions/ms-python.python-2023.22.1/pythonFiles/interpreterInfo.py
2024-01-22 04:42:34.424 [info] Python 解释器路径: /opt/homebrew/Caskroom/miniforge/base/bin/python
2024-01-22 04:42:34.654 [info] Send text to terminal: conda activate base
2024-01-22 04:42:34.654 [info] Send text to terminal: conda activate base
2024-01-22 04:42:34.655 [info] Send text to terminal: conda activate base
2024-01-22 04:42:35.523 [info] 正在启动 Pylance 语言服务器。
2024-01-22 04:42:59.166 [info] Running installed packages checker:  /opt/homebrew/Caskroom/miniforge/base/bin/python /Users/stephen/.vscode-server/extensions/ms-python.python-2023.22.1/pythonFiles/installed_check.py /Users/stephen/Works/repos/xSystemEm/pyproject.toml
2024-01-22 04:42:59.166 [info] > /opt/homebrew/Caskroom/miniforge/base/bin/python ~/.vscode-server/extensions/ms-python.python-2023.22.1/pythonFiles/installed_check.py ./pyproject.toml
2024-01-22 04:43:25.938 [info] Discover tests for workspace name: xSystemEm - uri: /Users/stephen/Works/repos/xSystemEm/pyhost/client.py
2024-01-22 04:43:25.948 [info] > conda run -n base --no-capture-output python ~/.vscode-server/extensions/ms-python.python-2023.22.1/pythonFiles/get_output_via_markers.py ~/.vscode-server/extensions/ms-python.python-2023.22.1/pythonFiles/printEnvVariables.py
2024-01-22 04:43:25.948 [info] shell: bash
2024-01-22 04:43:26.304 [info] > conda run -n base --no-capture-output python ~/.vscode-server/extensions/ms-python.python-2023.22.1/pythonFiles/get_output_via_markers.py ~/.vscode-server/extensions/ms-python.python-2023.22.1/pythonFiles/testing_tools/unittest_discovery.py . *test*.py
2024-01-22 04:43:26.304 [info] cwd: .
2024-01-22 04:43:26.653 [error] Error discovering unittest tests:
 Failed to import test module: pyhost
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.11/unittest/loader.py", line 452, in _find_test_path
    package = self._get_module_from_name(name)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.11/unittest/loader.py", line 362, in _get_module_from_name
    __import__(name)
  File "/Users/stephen/Works/repos/xSystemEm/pyhost/__init__.py", line 3, in <module>
    from . import message, server
  File "/Users/stephen/Works/repos/xSystemEm/pyhost/server/__init__.py", line 3, in <module>
    from .handlers import HmiCtrlMsgHandler, MicroDeviceMsgHandler
  File "/Users/stephen/Works/repos/xSystemEm/pyhost/server/handlers.py", line 12, in <module>
    from message.v1 import MessageHeader, MicroDevPositionReportReq
ModuleNotFoundError: No module named 'message'

User Settings


{
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": "always"
        },
    },
    "isort.args": [
        "--profile",
        "black"
    ],
    "file.autosave": "afterDelay",
}

Extension version: 2023.22.1
VS Code version: Code 1.85.2 (8b37750, 2024-01-18T06:40:10.514Z)
OS version: Windows_NT x64 10.0.22631
Modes:
Remote OS version: Darwin arm64 23.2.0

System Info
Item Value
CPUs 12th Gen Intel(R) Core(TM) i5-12490F (12 x 2995)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 31.82GB (16.93GB free)
Process Argv --crash-reporter-id e2d9c286-6e6f-4325-9431-3c2e100e1d4d
Screen Reader no
VM 0%
Item Value
Remote SSH: mbp2021-local
OS Darwin arm64 23.2.0
CPUs Apple M1 Pro (10 x 24)
Memory (System) 16.00GB (0.59GB free)
VM 0%
@karthiknadig
Copy link
Member

Python extension does not trigger code actions. VS Code should be the one getting this from all registered import organizers. Moving this to VS Code repo.

@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python Jan 22, 2024
@zhang-stephen
Copy link
Author

Python extension does not trigger code actions. VS Code should be the one getting this from all registered import organizers. Moving this to VS Code repo.

well, is the code action triggered by lsp client, vscode itself in this situation?

@karthiknadig
Copy link
Member

well, is the code action triggered by lsp client, vscode itself in this situation?

That is correct.

@mjbvz mjbvz assigned justschen and unassigned mjbvz Jan 22, 2024
@justschen justschen added the feature-request Request for new features or functionality label Jan 23, 2024
@justschen
Copy link
Contributor

related to discussion here: #200881

it's still under discussion atm

@vscodenpa vscodenpa added this to the Backlog Candidates milestone Jan 23, 2024
@justschen justschen added *duplicate Issue identified as a duplicate of another issue(s) and removed feature-request Request for new features or functionality labels Jan 23, 2024
@vscodenpa
Copy link

Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for similar existing issues. See also our issue reporting guidelines.

Happy Coding!

@vscodenpa vscodenpa closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2024
@microsoft microsoft deleted a comment from vscodenpa Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
*duplicate Issue identified as a duplicate of another issue(s)
Projects
None yet
Development

No branches or pull requests

5 participants