You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For a very long time I have been using an extra indent to distinguish continuation lines. This is defined as an option in PEP 8:
# Correct:# Aligned with opening delimiter.foo=long_function_name(var_one, var_two,
var_three, var_four)
# Add 4 spaces (an extra level of indentation) to distinguish arguments from the rest.deflong_function_name(
var_one, var_two, var_three,
var_four):
print(var_one)
# Hanging indents should add a level.foo=long_function_name(
var_one, var_two,
var_three, var_four)
I use this consistently for function definitions or any other line continuation. The rule is simple, and I find it significantly helps in distinguishing line continuations from blocks of code created by loops, branches, function/class definitions, etc. This is a silly example but it conveys the idea:
deffoo(
a: int, # argument indented twice to distinguish from body of functionb: float,
):
c=a+bif (c>20ora<0# line continuation indented to distinguish body of `if`orb>3):
c*=2d=bar(a=a,
b=b, # line continuation from function callc=c,
)
returnd
I have not used black because it eliminates the information provided by these extra indents. I would be thrilled if blue might support this. I could work on a PR if there is interest.
The text was updated successfully, but these errors were encountered:
This particular style choice of Black also troubles me. That's what motivated me to start a more configurable formatter based on a fork from Black: https://github.com/jsh9/cercis
My project already supports indenting by 8 spaces at function definitions. And I plan to add more configurable options.
Please feel free to try it out and provide feedback.
Thank you for starting this project!
For a very long time I have been using an extra indent to distinguish continuation lines. This is defined as an option in PEP 8:
I use this consistently for function definitions or any other line continuation. The rule is simple, and I find it significantly helps in distinguishing line continuations from blocks of code created by loops, branches, function/class definitions, etc. This is a silly example but it conveys the idea:
Real code examples can be seen here:
https://github.com/static-frame/static-frame/blob/master/static_frame/core/series.py
I have not used
black
because it eliminates the information provided by these extra indents. I would be thrilled ifblue
might support this. I could work on a PR if there is interest.The text was updated successfully, but these errors were encountered: