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.

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

2828 for group in groups[:-1]:
2929 didwrap = False # Only want to know about last group
3030 if len(group) > 1:
31+ # Don't wrap annotated assignment LHS;
32+ # (target: annotation) = value is invalid syntax.
33+ if ': ' in group:
34+ continue
3135 group.insert(0, '(')
3236 group.insert(-1, ')')
3337 didwrap = True

The check that tells the two apart

failpass·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