Skip to content

Python formatting very slow in Dev Container #18508

Closed
@adiun

Description

@adiun

Issue Type: Bug

Behaviour

Expected vs. Actual

Expected:

  • Fast to save a file with 'formatOnSave' set to true inside a dev container

Actual:

  • takes ~6 seconds to sort imports and then format code
  • Note: that it seems to be fast outside of a dev container
  • Note: This seems to have regressed with build 2022.01786462952. The build before it, 2021.12.1559732655 does not have this issue. The latest build, 2022.0.1814523869, still has this issue.

Steps to reproduce:

  1. Create a Dockerfile that:
    • Installs an editable poetry package
    • Here is the list of dev dependencies in pyproject.toml:
[tool.poetry.dev-dependencies]
bandit = "^1.7.1"
black = "^21.11b0"
flake8 = "^4.0.1"
isort = "^5.10.1"
markdown = "3.3.4"
pytest = "^5.2"
pytest-mock = "^3.6.1"
mkdocs = "^1.2.3"
mkdocstrings = "^0.16.2"
ipykernel = "^6.6.0"
pytest-recording = "^0.12.0"
  1. Create a devcontainer.json like this:
  "settings": {
    // Resolve import errors in Jupyter / ipython
    "[json]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[jsonc]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[python]": {
      "editor.tabSize": 4
    },
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
    },
    "editor.formatOnSave": true,
    "editor.tabSize": 2,
    "python.analysis.extraPaths": ["sdk"],
    "python.defaultInterpreterPath": "/opt/conda/bin/python",
    "python.formatting.provider": "black",
    "python.linting.banditEnabled": true,
    "python.linting.flake8Enabled": true,
    "python.testing.pytestEnabled": true,
    "python.testing.unittestEnabled": false,
    "terminal.integrated.inheritEnv": false
  },

  // Add the IDs of extensions you want installed when the container is created.
  "extensions": [
    "amodio.toggle-excluded-files",
    "bierner.markdown-emoji",
    "esbenp.prettier-vscode",

    "ms-python.python",
    "ms-python.vscode-pylance",
    "ms-toolsai.jupyter",
    "tamasfe.even-better-toml",
    "timonwong.shellcheck",
    "yzhang.markdown-all-in-one"
  ]

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.9.7
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
  • Value of the python.languageServer setting: Default
User Settings


defaultLS: {"defaultLSType":"Pylance"}

downloadLanguageServer: true

envFile: "<placeholder>"

venvPath: "<placeholder>"

venvFolders: "<placeholder>"

condaPath: "<placeholder>"

pipenvPath: "<placeholder>"

poetryPath: "<placeholder>"

languageServer: "Pylance"

linting
• enabled: true
• cwd: "<placeholder>"
• Flake8Args: "<placeholder>"
• flake8Enabled: true
• flake8Path: "<placeholder>"
• lintOnSave: true
• banditArgs: "<placeholder>"
• banditEnabled: true
• banditPath: "<placeholder>"
• mypyArgs: "<placeholder>"
• mypyEnabled: false
• mypyPath: "<placeholder>"
• pycodestyleArgs: "<placeholder>"
• pycodestyleEnabled: false
• pycodestylePath: "<placeholder>"
• prospectorArgs: "<placeholder>"
• prospectorEnabled: false
• prospectorPath: "<placeholder>"
• pydocstyleArgs: "<placeholder>"
• pydocstyleEnabled: false
• pydocstylePath: "<placeholder>"
• pylamaArgs: "<placeholder>"
• pylamaEnabled: false
• pylamaPath: "<placeholder>"
• pylintArgs: "<placeholder>"
• pylintPath: "<placeholder>"

sortImports
• args: "<placeholder>"
• path: "<placeholder>"

formatting
• autopep8Args: "<placeholder>"
• autopep8Path: "<placeholder>"
• provider: "black"
• blackArgs: "<placeholder>"
• blackPath: "<placeholder>"
• yapfArgs: "<placeholder>"
• yapfPath: "<placeholder>"

testing
• cwd: "<placeholder>"
• debugPort: 3000
• nosetestArgs: "<placeholder>"
• nosetestsEnabled: undefined
• nosetestPath: "<placeholder>"
• promptToConfigure: true
• pytestArgs: "<placeholder>"
• pytestEnabled: true
• pytestPath: "<placeholder>"
• unittestArgs: "<placeholder>"
• unittestEnabled: false
• autoTestDiscoverOnSaveEnabled: true

terminal
• activateEnvironment: true
• executeInFileDir: "<placeholder>"
• launchArgs: "<placeholder>"

experiments
• enabled: true
• optInto: []
• optOutFrom: []

insidersChannel: "off"

tensorBoard
• logDirectory: "<placeholder>"

Extension version: 2022.0.1814523869
VS Code version: Code 1.64.1 (d6ee99e4c045a6716e5c653d7da8e9ae6f5a8b03, 2022-02-07T17:26:08.977Z)
OS version: Darwin x64 20.6.0
Restricted Mode: No
Remote OS version: Linux x64 5.10.76-linuxkit

System Info
Item Value
CPUs Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 6, 4, 3
Memory (System) 32.00GB (0.20GB free)
Process Argv --crash-reporter-id 4758608f-d190-4905-8b7b-9580cf264aef
Screen Reader no
VM 0%
Item Value
Remote Dev Container: Sandbox
OS Linux x64 5.10.76-linuxkit
CPUs Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (8 x 2400)
Memory (System) 1.94GB (0.52GB free)
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyl392:30425749
pythontb:30283811
pythonvspyt551:30345470
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
pythondataviewer:30285071
vscod805cf:30301675
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
vsc1dst:30433059
pythonvs932:30410667
wslgetstarted:30433507
vsrem710:30416614
vsbas813:30436447
vscscmwlcmt:30433761

Metadata

Metadata

Assignees

Labels

area-formattingbugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions