Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yapf is not found as a formatter in vscode #1125

Closed
andrybicio opened this issue Aug 11, 2023 · 4 comments
Closed

Yapf is not found as a formatter in vscode #1125

andrybicio opened this issue Aug 11, 2023 · 4 comments

Comments

@andrybicio
Copy link

andrybicio commented Aug 11, 2023

I installed yapf in my virtual environment (Windows 11 + WSL2 with Ubuntu 20.04.6 LTS) using

pip install yapf

and it runs smoothly.

According to docs I read online, I needed to add in the settings.json file for the workspace the line:

{
  "python.formatting.provider": "yapf"
}

Note that whenever I try to modify the value of such a key, "yapf" is actually suggested as one of the options.

image

However, when running the command to format the document, it prompts that the default value for the formatter is black, but the latter cannot be found since I have uninstalled it.
image

I am suggested, then, to choose another one for my Workspace, and I would like it to be yapf, but it is not shown in the options I have.

image

Note that running in the shell, with the virtual environment activated that is the same one of the Python interpreter selected, yapf formats the file like a charm.

Any hints on how to make VSCode find yapf?

@unlsycn
Copy link

unlsycn commented Aug 14, 2023

The option "python.formatting.provider" is provided by Python extension as it calls yapf for formatting hence you should select "Python" as your formatter.
BTW, yapf support by Python extension is going to be deprecated, Seeing #1124 .

@andrybicio
Copy link
Author

That means are they planning to release a vscode extension for it? It seems to work and select the correct formatter, though. Thank you!

@Spitfire1900
Copy link
Contributor

Spitfire1900 commented Sep 5, 2023

See the community extension https://marketplace.visualstudio.com/items?itemName=eeyore.yapf

@Spitfire1900 Spitfire1900 mentioned this issue Sep 4, 2023
4 tasks
bwendling pushed a commit that referenced this issue Sep 18, 2023
Add instructions for common editors.

Closes #1124 and #1125
@Spitfire1900
Copy link
Contributor

@bwendling this may be closed as resolved by https://marketplace.visualstudio.com/items?itemName=eeyore.yapf and #1135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants