Hi Nicolas Goffin,
Thank you for reaching out to Microsoft Q & A forum.
The issue occurs because Black only supports formatting entire files, not specific code selections. To resolve this in Visual Studio Community, go to Tools > Options > Text Editor > Python > Code Style and disable selection-based formatting. Alternatively, save the file (Ctrl+S) to allow Black to format the entire document. You may also consider using a selection-based formatter like autopep8 or switch to Visual Studio Code for better compatibility with GitHub Copilot and Black.
Please feel free to contact us if you have any additional questions.
If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community.