Skip to content

YAPF seems to only run sometimes #1325

Closed

Description

Environment data

  • VS Code version: 1.21.1 (1.21.1)
  • Extension version (available under the Extensions sidebar): 2018.3.1 (29 Mar 2018)
  • OS and version: MacOS High Sierra
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda3
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: yapf==0.21.0

Actual behavior

I have the extension configured to run yapf on save. This works fine most of the time. However, seemingly when a file gets really large and complicated, even though the extension reports that yapf ran and completed (in the status bar), the file doesn't get formatted. If I try running it a few more times (e.g. add some extra unnecessary trailing spaces somewhere), it eventually does format the code. Running yapf on the command line consistently produces the same output, meaning I believe this is a bug with either VSCode or this extension. :)

Could it be a timeout issue? yapf takes too long so the extension gives up?

Expected behavior

yapf runs every time (and reports an error somehow if it failed).

Steps to reproduce:

?

Logs

  1. Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

    1. No yapf-associated logs are produced...
  2. Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

    1. Nothing.

Activity

  1. MikhailArkhipov commented on Apr 6, 2018

    @MikhailArkhipov

    Unfortunately, VS Code has time limit for formatting on save. Any save not completed within allocated time period is ignored with no notification to the user. We try and work around this by trying to detect if formatting produced edits but they were not applied but this workaround is not 100% bulletproof. See #624

    Now, apparently you can increase the time allotted according to microsoft/vscode#41194. Not very discoverable though. Try editor.formatOnSaveTimeout

  2. joshburkart commented on Apr 6, 2018

    @joshburkart
    Author

    Thanks for the info! I'll close this, since it's not a Python extension issue.

  3. locked as resolved and limited conversation to collaborators on Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions