Closed jvacek closed 3 months ago
Can you set this in your user settings, reload and repro the problem, and share the logs? ”black-formatter.trace.server”: “verbose”
logs should be under Output > Black Formatter.
Here you go:
@jvacek This might be an issue on black itself. We are running it with the ranges for the modified part, as you can see here in the logs:
/Users/jvacek/.pyenv/versions/3.10.3/envs/usermanagement/bin/python -m black -l 130 --line-ranges 141-149 --stdin-filename /Users/[redacted_path]/matching_tools/admin/missing_matchings.py -
but black is formatting the entire file.
The way to repro this locally, and exactly like the extension does with unsaved file is like this:
black
outside of VS Codecat <unformatted file path> | black -l 130 --line-ranges <start-line#>-<end-line#> --stdin-filename <unformatted file path> -
This will pass the file contents to black using stdin
and should behave exactly like how the extension triggers black. If the content that is printed out is fully formatted then it is a bug with black.
@karthiknadig Thanks, I have successfully repro'd this with black
itself (which i should have done to begin with hah 🙃). I opened an issue on the Black repo.
Depending on the outcome of the ticket above, would you consider adapting the input to black to not pass the last line of the file?
Depending on the outcome of the ticket above, would you consider adapting the input to black to not pass the last line of the file?
I don't fully understand, could you elaborate? are you suggesting to make the end-line value exclusive? or are you suggesting modify the content sent to black.
@karthiknadig the issue was fixed in black
, and is now available in 24.3.0. How often does the bundled version get bumped?
We will publish an update to this with the new black soon (likely early next week)
This is in pre-release
If you add new code to the bottom of the file, and format modifications, it will format the entire file.
I'm not sure whether this is specific to the extension or
black
itself.