One function
add_parens in berkerpeksag/astor
The author described this change as “Fix line wrapper producing invalid syntax for annotated assignments”. It counts as a record because the check below fails on the code as it stood at 760582d96 and passes on ea84a297e, with nothing else changed between the two runs.
Projectberkerpeksag/astor
Fix saved2026-02-17
Sharing licenceBSD-3-Clause · LICENSE
Change size+4 −0
What the code was meant to do, written into the code itself as a docstring
Attempt to add parentheses around the line in order to make it splittable.
The change
| 28 | 28 | for group in groups[:-1]: | |
| 29 | 29 | didwrap = False # Only want to know about last group | |
| 30 | 30 | if len(group) > 1: | |
| 31 | + | # Don't wrap annotated assignment LHS; | |
| 32 | + | # (target: annotation) = value is invalid syntax. | |
| 33 | + | if ': ' in group: | |
| 34 | + | continue | |
| 31 | 35 | group.insert(0, '(') | |
| 32 | 36 | group.insert(-1, ')') | |
| 33 | 37 | didwrap = True |
The check that tells the two apart
fail→pass·tests/test_code_gen.py::CodegenTestCase::test_long_annotated_assignment
Check file tests/test_code_gen.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 it760582d96cfc4372d2bda4879e17c0871c908f7c
Broken version dated2026-02-17
Moduleastor.source_repr
Units changedadd_parens
Fingerprinta861da0665e4473e
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 berkerpeksag/astor
- 2019-05-12MetaFlatten
- 2019-03-14Fix code generation with escaped braces in f-strings (#125)
- 2018-05-07Fix trailing newlines in f-strings (#103)