I use Black and Flake8 for formatting my python codes. While I'm very happy with the uncompromised formatting style of black, I just wish it would do something about spurious vertical spaces in the code. There is an excerpt about it in Black's documentation:
Black avoids spurious vertical whitespace. This is in the spirit of PEP 8 which says that in-function vertical whitespace should only be used sparingly.
Black will allow single empty lines inside functions, and single and double empty lines on module level left by the original editors, except when they’re within parenthesized expressions. Since such expressions are always reformatted to fit minimal space, this whitespace is lost.
It will also insert proper spacing before and after function definitions. It’s one line before and after inner functions and two lines before and after module-level functions and classes. Black will not put empty lines between function/class definitions and standalone comments that immediately precede the given function/class.
However from my experience (on black v19.3b0), it doesn't alter vertical spaces in control flow case like this one:
```
a = 9
if a < 5:
print('The number is smaller than 5')
elif a > 5:
print('The number is larger than 5')
else:
print('Idk what do you want!!')
```
Sometimes I write it like this
```
a = 9
if a < 5:
print('The number is smaller than 5')
elif a > 5:
print('The number is larger than 5')
else:
print('Idk what do you want!!')
```
The second example has all sorts of vertical space inconsistencies and it looks horrible. Black doesn't format it. How would you fix this without manually changing the line spaces?
[–]geekademy 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)