One function
_RetainVerticalSpacing in google/yapf
The author described this change as “fix #74, --lines over multiline strings erroneously inserted newlines”. It counts as a record because the check below fails on the code as it stood at f85517723 and passes on d9b5926bc, with nothing else changed between the two runs.
Projectgoogle/yapf
Fix saved2015-04-07
Sharing licenceApache-2.0 · LICENSE
Change size+4 −1
What the code was meant to do, written into the code itself as a docstring
Retain all vertical spacing between lines.
The change
| 2 | 2 | """Retain all vertical spacing between lines.""" | |
| 3 | 3 | if not prev_uwline: | |
| 4 | 4 | return | |
| 5 | - | prev_lineno = prev_uwline.last.lineno | |
| 5 | + | if prev_uwline.last.is_string: | |
| 6 | + | prev_lineno = prev_uwline.last.lineno + prev_uwline.last.value.count('\n') | |
| 7 | + | else: | |
| 8 | + | prev_lineno = prev_uwline.last.lineno | |
| 6 | 9 | if cur_uwline.first.is_comment: | |
| 7 | 10 | cur_lineno = cur_uwline.first.lineno - cur_uwline.first.value.count('\n') | |
| 8 | 11 | else: |
The check that tells the two apart
fail→pass·yapftests/yapf_test.py::CommandLineTest::testREtainingVerticalWhitespace
Check file yapftests/yapf_test.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itf85517723a65eef8134ff9ef60d1e68a9f48cf08
Broken version dated2015-04-07
Moduleyapf.yapflib.reformatter
Units changed_RetainVerticalSpacing
Fingerprint9dbb004f44189a3e
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in google/yapf
- 2015-03-26_NormalizeCode