Formatting: Format with Black, increase max line length to 100, combine multi-line blocks#178
Merged
Formatting: Format with Black, increase max line length to 100, combine multi-line blocks#178
Conversation
Formats all files with Black. Uses default line-limit of 88 characters. A lot of trailing commas were removed manually.
Format all code with Black using a line-limit of 100. This shortens many multi-line code blocks to a single line, making them more compact readable.
Remove trailing commas to combine multiple lines to a single line. A few edge-cases in which this degraded readability were not included (not visible in this commit). This should make code more compact while retaining or improving readability. Command used: black --line-length 100 -C See https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#trailing-commas
Owner
|
I like the way black handles the trailing comma and how you can use it to retain readability. I was wondering about this in the context of #170, so thanks for clarifying. I am torn on increasing the line limit. On the one hand, I agree with the improved readability. On the other hand, I often work on a laptop and then you can quickly run out of screen space in an IDE. 100 characters might offer a reasonable balance between these two concerns. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR does 3 thing, each in a separate commit:
black)black --line-limit 100)black --line-limit 100 -C)In each commit some edge cases were by hand removed to retain the best readability. The code now fully follows Black formatting.
The 100 character line limit was chosen because it increases readability by offering more code in a single view and allows for slightly longer (and thus more descriptive) variable names without expanding code to multiple lines.
The trailing comma handling by Black is is worth explaining a little. If Black detects a trailing comma, such as
it won't format the code to a single line. But if it doesn't detect a trailing comma, it does. So
becomes
This way you can control if you would like your code to stay in multi-line or be reduced to a single line.
@quaquel Could you let me know if you A) agree with the increased line limit of 100 characters and B) find that this improved readability generally? (I checked everything by hand but just for sure)
(please let me merge if everything is ok)