Skip to content

Handle when black times out formatting on save #3228

@fredrikaverpil

Description

@fredrikaverpil

Environment data

  • VS Code version: 1.28.2
  • Extension version (available under the Extensions sidebar): 2018.9.2
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): Miniconda Python 3.7
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
  • Relevant/affected Python packages and their versions: black 18.9b0

Actual behavior

When black fails to format on save due to timeout, there is no message in the output window, indicating this is the reason for not formatting the document.

Expected behavior

When black fails to format on save due to timeout, it would be useful to see some kind of warning about this in the output window. Not only in the developer tools console.

Steps to reproduce:

  1. Set "python.formatting.provider": "black", "editor.formatOnSave": true and save a large Python script (mine was 712 pep8-compliant rows).
  2. Save

Logs

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

Starting Jedi Python language engine.

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

WARN Aborted format on save after 750ms

Extra note

As a solution to the fact that black doesn't format a big file, increase the default "editor.formatOnSaveTimeout": 750 to a larger value in settings.json.

However, this issue is not about that, but rather the fact that it took me hours 🤕 to figure out WHY black was not formatting on save, as I was unaware of the developer tools console.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions