Prettier-vscode: Extension 'prettier - Code formatter' cannot format "hello.py"

Created on 24 May 2020  路  4Comments  路  Source: prettier/prettier-vscode

Summary

I used to write javascript only in vs code and everything works fine.
But now I start learning python.
When I hit ctrl-s will see this warning:
Extension 'prettier - Code formatter' cannot format "hello.py"

Github Repository to Reproduce Issue

https://github.com/krave1986/learn_python.git

Steps To Reproduce:

  1. clone the repo
  2. cd into the directory - hello
  3. open hello.py and hit ctrl + s

Expected result

No warning about prettier presents.

Actual result

Warning:
Extension 'prettier - Code formatter' cannot format "hello.py"

Additional information

VS Code Version:
1.45.1

Prettier Extension Version:
4.7.0

OS and version:
Windows 10

Prettier Log Output

no prettier button available in the bottom toolbar.

locked

Most helpful comment

For others who have met the same warning, please try to set a language-per formatter for python.

If you are like me who wants to use prettier for javascript as well as black for python, and you already have prettier set as the default editor for all languages in vs code via
"editor.defaultFormatter": "esbenp.prettier-vscode", you can set formatter specific for python:

    "[python]": {
        "editor.defaultFormatter": "ms-python.python",
    }

ms-python.python refers to the extension - python build by Microsoft which offers formatter options for python language. The options covers:
autopep8,
black,
yapf,
none

Info from here

All 4 comments

Saving the file will trigger the warning even if I have set .prettierignore to ignore hello.py

Prettier doesn鈥檛 support python.

For others who have met the same warning, please try to set a language-per formatter for python.

If you are like me who wants to use prettier for javascript as well as black for python, and you already have prettier set as the default editor for all languages in vs code via
"editor.defaultFormatter": "esbenp.prettier-vscode", you can set formatter specific for python:

    "[python]": {
        "editor.defaultFormatter": "ms-python.python",
    }

ms-python.python refers to the extension - python build by Microsoft which offers formatter options for python language. The options covers:
autopep8,
black,
yapf,
none

Info from here

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings