microsoft / vscode-black-formatter

Formatting support for Python using the Black formatter
https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter
MIT License
144 stars 34 forks source link

Does not understand how to format double quotation ("") in f-string in Python 3.12 #456

Closed HiroshiAhsan closed 3 months ago

HiroshiAhsan commented 5 months ago

Currently using VSCode 1.86.1 with Black Formatter v2024.0.0.

The Formatter does not understand how to format double quotation ("") in f-string (PEP 701) in Python 3.12.

karthiknadig commented 5 months ago

@HiroshiAhsan Can you provide an example? Also can you verify if the black itself handles it correctly?

Linux/Mac:

cat yourcode.py | black --stdin-filename yourcode.py -

Windows:

type yourcode.py | black --stdin-filename yourcode.py
karthiknadig commented 3 months ago

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on then we will be happy to re-open this issue to pick up where we left off.

DeveloperAnonymous commented 3 months ago

Hi @karthiknadig, I just found this and assuming I understand it correctly, I can provide an example in their place: image

Basically in previous Python versions having double quotes in an f-string like this f"BattleBanana Leaderboard on {details["server_name_clean"]}" was not supported and acted like black does right now. It needed single quotes like this: f"BattleBanana Leaderboard on {details['server_name_clean']}"

However with more research, this seems more on Black than the plugin itself, they didn't implement support for PEP 701 yet: https://github.com/psf/black/issues/3746