When I get the warning
PEP 8: E122 continuation line missing indentation or outdented
Ctrl + Alt + L doesn't perform the necessary indenting. Instead, the indenting has to be done manually.
As if that wasn't enough, if I do Ctrl + Alt + L afterwards, the line gets unindented to the previous, incorrect level, which raises the aforementioned warning again. What's the solution to this pesky nuisance?
As asked, here's an example:
def foo():
return range(15)
var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, \
var15 = foo()
Editor -> Code Style -> Markdown
settings:
Hard wrap = 80
Wrap on typing = Yes
.
PyCharm has some builtin functionalities that do automatically correct the continuation line indentation, but no for the specific case shown in the question.
The shown code is Python so the corresponding settings are at File
>
Settings
>
Editor
>
Code Style
>
Python
>
Wrapping and Braces
.
If you look at the screenshot, the functionality you want works for the available options called Wrap if long
(used together with the Hard wrap at
limit). If you try the same for any of the constructs that have the previous option (for example the imports) the continuation line indentation is automatically correct by pressing Ctrl + Alt + L. However, your example is for multiple attribute declarations in a single line with unpacking for which there is no option.
This leaves users with 3 common alternatives:
But in conclusion this isn't due to anything you are doing wrong and there isn't a hidden setting somewhere that would enable this. The IDE simply doesn't have the formatting feature for this specific construct.
You can also post a feature request at JetBrains bugtracker.