microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.34k stars 1.19k forks source link

No python formatter installed - Local new setup or Github codespace with python extension + formatter installed #22897

Open tyeth opened 9 months ago

tyeth commented 9 months ago

There are issues with formatting Python files in Codespaces due to deprecated settings.

If the user has the python extension installed with pylance and pylint and expected default installed formatters (with Microsoft Python related extensions), then they should be able to instantly format python files.

See #22363 #18743 #22412 also just open ANYTHING in a new vscode or ideally github codespace and try to format a python file. It offers to install a python formatter, like this extension, then after install continues to not have an installed available python formatter, purely because configuring settings in VS Code is painful.

Originally I was using this locally, but after realizing it's probably easier in a Github codespace I then found that's beyond help too. Maybe try automatically migrating or remove incompatible settings, and merge in new defaults if required (like the default python formatter once installed as part of the Microsoft Python/Pylance extensions).

Recreation steps:

Create a new github codespace, pointing to repo tyeth/Adafruit_CircuitPython_PyCamera Branch: wifi-qrsetup Then goto examples/qrio-update-wifi/code.py and try to format the file. Install top suggested extension for python formatters (Microsoft Python extension). Reload window. Try to format file again, find there is still no formatter installed in theory.

luabud commented 9 months ago

Hi @tyeth, I made some updates to your comment to align with our code of conduct.

In the mean time, could you try using the following setting in your Codespaces settings?

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

I think this is a good request to track with this issue:

Maybe try automatically migrating or remove incompatible settings, and merge in new defaults if required (like the default python formatter once installed as part of the Microsoft Python/Pylance extensions).

tyeth commented 9 months ago

Thanks, having now had to extensively read the docs I can see the options for autopep8, black etc, which I'm sure your suggested settings change would resolve. Personally I'm required to use pylint followed by black, but that's semi-irrelevant. However as I'm sure you appreciate, the point of codespaces to me is low friction, not customising vscode settings to achieve basic functionality, so yeah I'm happy for this issue to be used to track the settings migration / default formatter