Invalid code generated for `Comparison` with missing parens
- Dominant language
- Python
- Stars
- 1.9k
- Forks
- 229
- PR merge metrics
- No merged PRs in 30d
Description
```python
from libcst import *
node = Comparison(
left=Name("a"),
comparisons=[
ComparisonTarget(
Equal(whitespace_before=ParenthesizedWhitespace(indent=True)),
Name("b"),
),
],
)
code = Module([]).code_for_node(node)
parse_module(code) # error, invalid syntax!
```
Related to #287 and #531; found via https://github.com/Zac-HD/shed/issues/84.
Contributor guide
Research direction
Start by running the provided Python reproduction and trace `Module([]).code_for_node` through `Comparison` serialization. Add a regression test for the missing-parentheses case, with completion defined as generated code that `parse_module` accepts without a syntax error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100