Strip trailing whitespace in descriptions to avoid messy formatting#51
Open
LourensVeen wants to merge 2 commits into
Open
Strip trailing whitespace in descriptions to avoid messy formatting#51LourensVeen wants to merge 2 commits into
LourensVeen wants to merge 2 commits into
Conversation
maarten-ic
approved these changes
May 26, 2026
Collaborator
maarten-ic
left a comment
There was a problem hiding this comment.
One suggestion for improvement, but the changes look good to me!
Comment on lines
+136
to
+140
| ynode = cast(yaml.ScalarNode, descr.yaml_node) | ||
| ynode.style = '|' | ||
| if not ynode.value.endswith('\n'): | ||
| ynode.value += '\n' | ||
| # remove trailing whitespace to ensure PyYAML actually uses block style | ||
| ynode.value = '\n'.join([ | ||
| line.rstrip() for line in ynode.value.split('\n')]) + '\n' |
Collaborator
There was a problem hiding this comment.
Perhaps make this a utility method instead of repeating in 4 places?
Contributor
Author
There was a problem hiding this comment.
Did that and it does look cleaner, but it's also more code. What do you think? Or are we bikeshedding too much already? 😄
Collaborator
There was a problem hiding this comment.
Ah, I meant to create a method:
def set_block_style(ynode: yaml.ScalarNode) -> None:
ynode.style = "|"
# remove trailing whitespace to ensure PyYAML actually uses block style
ynode.value = '\n'.join([
line.rstrip() for line in ynode.value.split('\n')]) + '\n'But fine to keep it like this.
Or are we bikeshedding too much already? 😄
Not really worth spending much more time on it indeed 🙂
Contributor
Author
There was a problem hiding this comment.
Hmm, but now I can't unsee it. And I've realised that this should be in yatiml.Node...
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.
Addresses #38