Spaces for indentation are a sin against *.deity, especially for python! Why would you use mulitples of alignment characters for an indentation-sensitive language?
After trying a handful of formatters out there, Black did the best job for my tastes. Except for its enshittification of indentations.
VSCode has built-in converters for indentation, which is great, and they can be used to repair Black's errors;
- First convert the code to Space indent to make Black happy ( optional due to an old black-specific bug psf/black#3667 )
- Run Format Doucument (using default formatter, so this can be language independent)
- Convert back to Tabs
And you can write a VSCode task for this to go in 1 click/keypress!
Put in your tasks.json (File > Preferences > Tasks):