Open stewartadam opened 4 months ago
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.
Repro repo: https://github.com/stewartadam/devcontainer-repro
Configure settings as per :
{ "[python]": { "editor.defaultFormatter": "charliermarsh.ruff", "editor.codeActionsOnSave": { "source.organizeImports": "explicit" }, "editor.formatOnSave": true } }
Edit a Python file (locally) and format it badly, unorder the imports
Save file -> code actions are applied
Rebuild the devcontainer in the sample repo and attempt the same steps
Python
Output
View
``` 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 ```
Python extension actually does not trigger this. This comes from core. Moving this to VS Code.
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
Configure settings as per :
Edit a Python file (locally) and format it badly, unorder the imports
Save file -> code actions are applied
Rebuild the devcontainer in the sample repo and attempt the same steps
Diagnostic data
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)``` 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 ```