Whole file
t3rn0/ast-comments
The author described this change as “fix: handle multiple statements in one line”. It counts as a record because the check below fails on the code as it stood at ac4dc0019 and passes on 8a50afae7, with nothing else changed between the two runs.
Projectt3rn0/ast-comments
Fix saved2022-11-13
Sharing licenceMIT · LICENSE
Change size+4 −3
What the code was meant to do, written into the code itself as a save note
fix: handle multiple statements in one line
The change
| 36 | 36 | comment_tokens = sorted( | |
| 37 | 37 | (x.start[0], x) for x in tokens if x.type == tokenize.COMMENT | |
| 38 | 38 | ) | |
| 39 | - | nodes = sorted([(x.lineno, x) for x in ast.walk(tree) if isinstance(x, ast.stmt)]) | |
| 40 | - | ||
| 39 | + | nodes = sorted( | |
| 40 | + | (x.lineno, x.col_offset, x) for x in ast.walk(tree) if isinstance(x, ast.stmt) | |
| 41 | + | ) | |
| 41 | 42 | i = j = 0 | |
| 42 | 43 | while i < len(comment_tokens) and j < len(nodes): | |
| 43 | 44 | t_lineno, token = comment_tokens[i] | |
| 44 | - | n_lineno, node = nodes[j] | |
| 45 | + | n_lineno, _, node = nodes[j] | |
| 45 | 46 | if t_lineno <= n_lineno: | |
| 46 | 47 | node.comments += (format_comment(token.string),) | |
| 47 | 48 | i += 1 |
The check that tells the two apart
fail→pass·test_ast_commets.py::test_multiple_statements_in_line
Check file test_ast_commets.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 itac4dc0019ddadc1744ba456f473fb624e13eccdb
Broken version dated2022-08-03
Moduleast_comments
Units changed_enrich
Fingerprintcb86cec6d80b5937
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.