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

No such option: --stdin-filename #468

Closed yogurfrul closed 4 months ago

yogurfrul commented 4 months ago

when I upgrade vscode ,found python formatter must use vscode-black-formatter,old python.formatting become unknown. ok,fine, I use it。Then I found my local black not work with log: `2024-02-23 14:31:10.778 [info] /home/user/.local/bin/black --line-length=100 --stdin-filename /home/user/code.py - 2024-02-23 14:31:10.779 [info] CWD Server: /home/user 2024-02-23 14:31:11.045 [info] Usage: black [OPTIONS] [SRC]... Try 'black -h' for help.

Error: No such option: --stdin-filename`

my local black version is 20.8b1, I know it's old, because I work on old code with many others. maybe this line should check the black version: https://github.com/microsoft/vscode-black-formatter/blob/01e3899d1e3d1fd85bf3010107f4361a136f2e04/bundled/tool/lsp_server.py#L175

karthiknadig commented 4 months ago

The minimum version of black supported by this extension is 22.0.*. We don't have plans to support older versions of black. The main reason is that older versions of black did not have a way to format virtual or unsaved files. I recommend pinning your python extension to older version where you could use it.