-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Don't trim last empty line in docstrings #9813
Conversation
b0fcb7f
to
560ce50
Compare
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.
Nice fix! This is why bstr
has a lines_with_terminator
method. ;-)
|
560ce50
to
b70ca90
Compare
Summary
This PR fixes a bug in our formatter where it would remove the last empty line for docstrings when
"""
is not intented:Would get formatted to
(Removing the last empty line).
This is inconsistent with Black and how we format docstrings when the closing quotes are indented. The empty line does not get removed for:
The root cause of the divergence was that we use
str::lines()
which usessplit_inclusive
underneath that omits the last element if it matches the separator:The PR fixes the divergence by using
split
instead.Fixes #9804
Preview
This change is not gated behind preview because it doesn't change the output for already formatted code.
Test Plan
Added snapshot test