microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.65k stars 29.43k forks source link

Code actions on save in [python] section when ignored running in devcontainer #217727

Open stewartadam opened 5 months ago

stewartadam commented 5 months ago

Behaviour

Preferences for code actions on save (e.g. formatting or sorting imports) are ignored under the language-specific [python] section when running in a devcontainer.

Steps to reproduce:

Repro repo: https://github.com/stewartadam/devcontainer-repro

  1. Configure settings as per :

    {
    "[python]": {
    "editor.defaultFormatter": "charliermarsh.ruff",
    "editor.codeActionsOnSave": {
      "source.organizeImports": "explicit"
    },
    "editor.formatOnSave": true
    }
    }
  2. Edit a Python file (locally) and format it badly, unorder the imports

  3. Save file -> code actions are applied

  4. Rebuild the devcontainer in the sample repo and attempt the same steps

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

``` 2024-06-24 23:56:25.766 [info] Experiment 'pythonCreateEnvOnPipInstall' is active 2024-06-24 23:56:25.766 [info] Experiment 'pythonRecommendTensorboardExt' is active 2024-06-24 23:56:25.766 [info] Experiment 'pythonSurveyNotificationcf' is active 2024-06-24 23:56:25.766 [info] Experiment 'pythonTerminalEnvVarActivation' is active 2024-06-24 23:56:25.766 [info] Experiment 'pythonTestAdapter' is active 2024-06-24 23:56:25.766 [info] Default formatter is set to null for workspace /workspace 2024-06-24 23:56:25.766 [info] Python interpreter path: ./.venv/bin/python 2024-06-24 23:56:26.148 [info] > pyenv which python 2024-06-24 23:56:26.148 [info] cwd: . 2024-06-24 23:56:26.173 [info] > conda info --json 2024-06-24 23:56:26.278 [info] > . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode-server/extensions/ms-python.python-2024.8.1/python_files/printEnvVariables.py 2024-06-24 23:56:26.278 [info] shell: bash 2024-06-24 23:56:26.320 [info] > /usr/bin/python3 ~/.vscode-server/extensions/ms-python.python-2024.8.1/python_files/printEnvVariables.py 2024-06-24 23:56:26.320 [info] shell: bash 2024-06-24 23:56:26.335 [info] Setting environment variable VIRTUAL_ENV in collection to /workspace/.venv {"applyAtShellIntegration":true,"applyAtProcessCreation":true} 2024-06-24 23:56:26.335 [info] Setting environment variable VIRTUAL_ENV_PROMPT in collection to workspace-3.11 {"applyAtShellIntegration":true,"applyAtProcessCreation":true} 2024-06-24 23:56:26.335 [info] Prepending environment variable PS1 in collection with workspace-3.11 {"applyAtShellIntegration":true,"applyAtProcessCreation":false} 2024-06-24 23:56:26.335 [info] Prepending environment variable PATH in collection with /home/vscode/.vscode-server/extensions/ms-python.python-2024.8.1/python_files/deactivate/bash:/workspace/.venv/bin: {"applyAtShellIntegration":true,"applyAtProcessCreation":true} 2024-06-24 23:56:26.335 [info] Send text to terminal: /usr/bin/python3 /home/vscode/.vscode-server/extensions/ms-python.python-2024.8.1/python_files/printEnvVariablesToFile.py /home/vscode/.vscode-server/extensions/ms-python.python-2024.8.1/python_files/deactivate/bash/envVars.txt 2024-06-24 23:56:27.119 [info] Starting Pylance language server. 2024-06-24 23:56:29.301 [info] Discover tests for workspace name: workspace - uri: /workspace/src/example-flow/hello.py 2024-06-24 23:56:31.298 [info] Discover tests for workspace name: workspace - uri: /workspace/src/example-flow/hello.py 2024-06-24 23:59:57.685 [info] Discover tests for workspace name: workspace - uri: /workspace/src/example-flow/hello.py 2024-06-24 23:59:58.762 [info] Discover tests for workspace name: workspace - uri: /workspace/src/example-flow/hello.py 2024-06-24 23:59:59.988 [info] Discover tests for workspace name: workspace - uri: /workspace/src/example-flow/hello.py ```

karthiknadig commented 5 months ago

Python extension actually does not trigger this. This comes from core. Moving this to VS Code.