cst.IfExp test/body print order differs from lexical order in code
- Dominant language
- Python
- Stars
- 1.9k
- Forks
- 229
- PR merge metrics
- No merged PRs in 30d
Description
`leave_IfExp_body` is executed before `leave_IfExp_test`, which I think is by design since the body appears before the test in code (although impractical in my case since it can otherwise be treated just like an `If`), but when printing an `IfExp` it prints the `test` before `body` - which made it quite confusing to figure out what was going on.
The `__init__` also has it's `test` argument before `body`.
```python
cst.parse_expression('True if False else None')
Out[19]:
IfExp(
test=Name(
value='False',
lpar=[],
rpar=[],
),
body=Name(
value='True',
lpar=[],
rpar=[],
),
orelse=Name(
value='None',
lpar=[],
rpar=[],
),
lpar=[],
rpar=[],
whitespace_before_if=SimpleWhitespace(
value=' ',
),
whitespace_after_if=SimpleWhitespace(
value=' ',
),
whitespace_before_else=SimpleWhitespace(
value=' ',
),
whitespace_after_else=SimpleWhitespace(
value=' ',
),
)
```
Contributor guide
Assessment
This issue has not been assessed yet.