I have some python code that I run through pylint and that I decided to also run through pycodestyle.
To avoid long lines in a with statement, I do the following:
with my_context_manager(
argument1,
argument2) as something:
rest_of_my_code
But pycodestyle tells me that
E125 continuation line with same indent as next logical line
So I indent this further, as follows:
with my_context_manager(
argument1,
argument2) as something:
rest_of_my_code
But now pylint tells me:
Wrong hanging indentation (remove 4 spaces).
Is there a better solution that would satisfy both code quality checkers?
Note 1
The following raises no complaints from either of the two style checkers provided that the lines are not too long (which unfortunately is not always the case):
with my_context_manager(argument1,
argument2) as something:
rest_of_my_code
Note 2
To answer comments, I tried the following:
with my_context_manager(
argument1,
argument2) as something:
rest_of_my_code
Strangely pycodestyle still says E125 continuation line with same indent as next logical line about the same line as previously (the one with argument2).
I formatted the code the following way ...
with my_context_manager(
argument1,
argument2
) as something:
rest_of_my_code
... and did not get any complaints from pylint and pycodestyle.
You can disable the check in pylint (in .pylintrc add bad-continuation to the disable option in the MESSAGE CONTROL section of the file).
~/.pylintrc
[MESSAGES CONTROL]
disable=bad-continuation,...
See the FAQ for more about message-control config
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With