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
PEP 8 doesn't have anything regarding this style, so it can't serve as a reference. pycodestyle currently expects the expression to proceed at the indent level of the opening paren.
I just checked again and found this kind of indentation is the recommended style of using method chaing as shown in this tutorial linked from the official pandas website.
I don't really see how to stick to the E127 rule and write readable code at the same time, since you will probably agree that this consumes too much space:
@chaoflow Thanks for the hint! However that does not really solve to problem, as it triggers E126 in the line starting with .drop(labels...) and claiming it to be over-indented.
At least emacs with python-mode will auto-align on the former and using the tab key it won't settle for more indentation (the latter), which means to support the latter, there is at least one more tool to be convinced.
My conclusion: pycodestyle should at least support the backslash use case and it would be great if the over-idented within parentheses use case would be supported as well, though there would be at least one editor to be taught to make use of it.
As already mentioned, pep8 says nothing about dotted continuation lines within parentheses.
Activity
FichteFoll commentedon Dec 18, 2019
PEP 8 doesn't have anything regarding this style, so it can't serve as a reference. pycodestyle currently expects the expression to proceed at the indent level of the opening paren.
fgotzens commentedon Dec 19, 2019
@FichteFoll Hm, okay, thank you for your reply!
I just checked again and found this kind of indentation is the recommended style of using method chaing as shown in this tutorial linked from the official pandas website.
I don't really see how to stick to the E127 rule and write readable code at the same time, since you will probably agree that this consumes too much space:
and this is more than ugly:
So how do you think we should proceed here?
chaoflow commentedon Jan 13, 2020
@fgotzens instead of the outer parentheses, you could use backslashes to escape the line breaks:
fgotzens commentedon Jan 13, 2020
@chaoflow Thanks for the hint! However that does not really solve to problem, as it triggers E126 in the line starting with
.drop(labels...)and claiming it to be over-indented.chaoflow commentedon Jan 13, 2020
@fgotzens I see the problem. We work around this by using pylint as well and disabling E126 for flake8, see https://gitlab.com/ternaris/marv-robotics/blob/master/setup.cfg
sigmavirus24 commentedon Jan 13, 2020
The backslash is a hideous way to work around this problem, in my opinion
chaoflow commentedon Jan 13, 2020
@sigmavirus24 An indisputable case would be:
versus over-idented within parentheses
At least emacs with python-mode will auto-align on the former and using the tab key it won't settle for more indentation (the latter), which means to support the latter, there is at least one more tool to be convinced.
Given that so far I use:
or
or, if the
xyzis needed anyway:My conclusion: pycodestyle should at least support the backslash use case and it would be great if the over-idented within parentheses use case would be supported as well, though there would be at least one editor to be taught to make use of it.
As already mentioned, pep8 says nothing about dotted continuation lines within parentheses.
[-]E127 method chaining[/-][+]E127: method chaining[/+]