-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
STY: make allowed line length 9 longer to 88 from 79 #24893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
STY: make allowed line length 9 longer to 88 from 79 #24893
Conversation
I guess we should have some sort of policy about reflow PRs. I'm not looking forward to 100s of those (or a few giant ones). |
For now, let's not do any reflow at all. Only new / changed code should use the increased line length. IMHO many small reflow PRs do not make sense. We can later decide whether we want to do one large one, possibly related to the decision whether we want to use black style. |
I'd say that the policy is:
(For code I expect that there will be fewer changes in practice.) |
Sorry I missed the call, but can one briefly remind what arguments were put forward in favor of this change? In particular I find black's argument (https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length)
quite dishonest, given that black tends to produce many, many lines with just punctuation (e.g. closing parentheses and brackets), so if you care about file length you should just not put trailing punctuation on its own line and you'll save much more than by bumping the line length limit from 79 to 88. In fact, sometimes in Matplotlib we do put trailing punctuation by itself on a separate line, but the whole point is that it depends on the semantics of the code, and is not something we do all the time. |
I must stress that although I sometimes use black in projects (because other people encourage it or are really bad at manual formatting), I do tend to be quite appalled quite a lot of the time, so I also hope that this change is not a step in that direction. (I hope/guess that the argument is that doc-strings can sometimes be quite narrow if they show up on a high tab-level. Also, many nested tab-levels combined with long variable names sometimes make it hard to avoid doing |
While I have an ambivalent opinion on black, the line length choice seems reasonable. Maybe black's explanation is a bit sloppy. IMHO less number of lines (=more content on the screen) is only the secondary reason for longer lines. The greater benefit of less wrapping is more "one line = one statement", which increases readability - as long as the lines are not too long. I also have the feeling that 79 is a bit too tight. If black has found out that 88 chars produce significant less wrapping, that's a valuable result, irrespective of their other style decisions. Unless we have good reasons for a different line length, I think 88 is a good number. |
On the call, there was no question of actually starting to use black, just that it was reasonable to choose a line length consistent with their default. The original proposal was a line length of 115. Definitely, any discussion about switching to black would be very broad. |
This was the part of the black documentation I was trying to reference. |
(I can just note that assembly rarely has the issue of line length...) Is this ready to review now that 3.7 is branched? There seems to be some sort of common understanding in the discussions here as well:
Only question is if we should document any policy about reflowing? I may doubt that the average contributor may not note this. There are currently some (parts of) files which could be reflowed and I have not seen any such PRs during my year involved so I do not really think that we should expect that many now. If we do, we can add a policy? |
I would have thought that the vast majority of contributors have no more interest in writing a reflow PR than we have in reviewing one. For any that do, I think it would be reasonable to respond along the lines of “the benefits of this change do not outweigh the effort of reviewing it or the risk of unintended functional changes”, without needing to point to a specific written policy. The PR guidelines currently state that we conform to PEP8, so possibly that text should be tweaked. |
The outstanding tasks are:
|
I have added notes for each of the highlighted outstanding tasks. I did not touch MEP8, which is the other place we discuss Matplotlib style outside of release notes as it is my understanding that the MEPs are largely not being used/updated anymore. |
2cd570b
to
2061607
Compare
|
||
The maximum line length for new contributions has been extended from 79 characters to | ||
88 characters. | ||
This change provides an extra 9 characters to allow code which is a single idea to fit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the wrapping here is somehow trying to tell me something ;-)
Other line lengths considered included 115 and 99, but ultimately 88 characters was the | ||
consensus as it is relatively conservative while still providing reasonable benefit. | ||
The ability to view side-by-side git diffs was a key point in choosing the smaller | ||
limit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a more serious note, I wonder about putting too much of our back and forth in the API note. Maybe just say we chose 88, its consistent with black, but we may relax further if there is a good reason...
doc/devel/coding_guide.rst
Outdated
* Is the change only reflowing code/docstrings for increased line length? | ||
Generally, such changes are discouraged when not part of other non-stylistic | ||
work because it obscures the git history of functional changes to the code. | ||
Reflowing a method or docstring as part of a larger refactor/rewrite is | ||
acceptable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seemed a little out of left-field - maybe more general is better?
* Is the change only reflowing code/docstrings for increased line length? | |
Generally, such changes are discouraged when not part of other non-stylistic | |
work because it obscures the git history of functional changes to the code. | |
Reflowing a method or docstring as part of a larger refactor/rewrite is | |
acceptable. | |
* Is the change just stylistic? Generally, such changes are discouraged when not | |
part of other non-stylistic work because it obscures the git history of functional | |
changes to the code. Style changes to a method or docstring as part of a larger | |
refactor/rewrite is acceptable. |
* Is the change only reflowing code/docstrings for increased line length? | |
Generally, such changes are discouraged when not part of other non-stylistic | |
work because it obscures the git history of functional changes to the code. | |
Reflowing a method or docstring as part of a larger refactor/rewrite is | |
acceptable. | |
* Is the change only reflowing code/docstrings for increased line length? | |
Generally, such changes are discouraged when not part of other non-stylistic | |
work because it obscures the git history of functional changes to the code. | |
Reflowing a method or docstring as part of a larger refactor/rewrite is | |
acceptable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems good to me. A couple of small suggestions you can take or leave...
@meeseeksdev backport to v3.7.0 |
Something went wrong ... Please have a look at my logs. It seems that the branch you are trying to backport to does not exist. |
@meeseeksdev backport to v3.7.x |
As discussed on the call this week, we should consider making the style enforced line length slightly longer.
Going to 88 matches the default of black. https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length is a nice explanation of how they landed there.
Key points from the call:
There are no plans to re-flow the entire code base, but new stuff could come in more relaxed.