Skip to content

Black format on save conflicts with isort on save #5545

Closed

Description

@sbstp

Environment data

  • VS Code version: 1.33.1
  • Extension version (available under the Extensions sidebar): 2019.4.12954
  • OS and version: Kubuntu 18.04
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.7
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
  • Relevant/affected Python packages and their versions: lastest black

Expected behaviour

My code should get formatted by black and the imports should get sorted by isort when I save my file.

Actual behaviour

Only the imports get sorted. The code does not get formatted.

Steps to reproduce:

  1. This is the relevant config section
"python.pythonPath": "/usr/bin/python3",
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
    "-l",
    "120"
],
"[python]": {
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
        "source.organizeImports": true
    }
},
  1. Type up some code with bad formatting and unsorted imports
  2. Save the file

Logs

 WARN Aborted codeActionsOnSave after 750ms

Well, it seems like this is the issue. I added

"editor.formatOnSaveTimeout": 3000,
"editor.codeActionsOnSaveTimeout": 3000,

which I saw in another issue and it fixed the problem. Perhaps something can be done upstream to make them run faster or simply increase the default timeout for that case.

Activity

  1. ghost added
    triage-neededNeeds assignment to the proper sub-team
    on May 3, 2019
  2. DonJayamanne commented on May 16, 2019

    @DonJayamanne

    Closing in favor of #1357

  3. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on May 16, 2019
  4. locked as resolved and limited conversation to collaborators on Jun 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions