keep maximum blank lines not working?

In my python code style I have "Keep Maximum Blank Lines" set to 9 lines.  However, when I trigger reformat code, all multiple blank lines  in my function are reduced to a single blank line.  Am I missing something?  Is this broken?





It seems you wold like to keep a certain minimum amount of blank lines between any statements inside an arbitrary function/method. Unfortunately it is not possible to exclude the removal of such lines during the reformat procedure, as it goes against convention and best practices.


I'm confused as to what those two options under "keep maximum blank lines" mean.  Could you clarify what they do?


Well, it's "keep maximum", so it means there's shouldn't be more that specified number of lines anywhere in the code or in declarations.

But from what I understand, you're looking for the minimum number of lines, not maximum. Since you want a certain minimum number of lines to always present (correct me if I'm wrong).

But none of the options under "minimum lines" affects the lines inside the function declaration, as in your example, it seems. I've tested it. We can submit a feature request, but it needs to be backed up by a strong use case or convention.


I'm not sure that makes sense to me.

If there shouldn't be any more blank lines than the specified number, shouldn't that mean the code cleanup should ignore the number of blank lines less than the specified number?  I'm expecting the code cleanup to ignore the number of blank lines up to the setting when it finds them.  And if it comes across a number greater than the setting, it would reduce down to that limit.  

The minimum number of lines would mean that if I didn't put a blank line between lines, code cleanup would insert them for me. In fact you can see this is working when you set the min blank lines "after top level imports".  Code cleanup will put an extra blank line between the imports and the first line of code.  This is as expected.


The documentation lends itself to something along those lines as well.  What I'm unsure of where in the code these styles are applied.  

I assume 'In declarations' means within any def (function or method).  I'm not sure if this would apply to classes.
I don't know what 'In code' means, though I suspect it applies to anything outside any declaration.


After digging a bit further, I gotta say you are correct. There are two issues:

1. The names are misleading. "In declarations" should actually be named "Around declarations", like class or functions, and "In code" means the rest of the code, like the code inside class/function

2. "In code" setting should actually do what you need, but it seems that it's currently ignored. This setting was inherited from the IDEA and in the context of Python wasn't implemented properly. Seems to be not a widely used feature since it wasn't brought up until now.

I've created a ticked in our issue tracking system:

Please follow this ticket, the fix should be due soon.


Thank you so much for the explanation.  

Should I create a ticket to better explain/change explanation for the names?  


Already created:

You're welcomed to suggest your own names in the comments.


Please sign in to leave a comment.