Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make code formatting work again for Python (Visual Studio Code on Mac)?

On Mac, Option +Shift + F now brings up the "There is no formatter for 'python' files installed." message box:

I tried installing this plugin, without a change seen to this situation:

I already have these two plugins installed for Python:

However as @starball mentioned, it may have reduced support now.

So according to the new world, is there a different way that I can get the on-demand (keyboard shortcut based) automatic code formatting for Python in VSCode to work?

Versions:

  • VS Code: 1.91.1 (Universal)
  • Python: 3.12.4
like image 214
SydMK Avatar asked Nov 19 '25 12:11

SydMK


1 Answers

Once VSCode Python's format feature came from the python package, VSCode now offers smarter and more customizable extensions.

autopep8 and Black formatter were provided by Microsoft.

Ruff and yapf were provided by community.

Once you install a formatter extension, you can select it as the default formatter for Python files in VS Code by following the steps below:

  1. Open a Python file in VS Code.
  2. Right-click on the editor to display the context menu.
  3. Select Format Document With....
  4. Select Configure Default Formatter... from the drop-down menu.
  5. Select your preferred formatter extension from the list.

You could read document about Formatting in vscode-python for more details.

like image 67
MingJie-MSFT Avatar answered Nov 22 '25 00:11

MingJie-MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!