Instagram / Instagram/LibCST

Add validation for `with` nodes to match `if`, `while`, `assert`

Open
#1,224 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.9k
Forks
229
PR merge metrics
No merged PRs in 30d

Description

I believe that after v1.5.0 , `with` nodes are the only case of a keyword followed by an expression with
- optional space after the keyword
- missing validation that some non-empty whitespace is present on non-parenthesized expressions

---

I have some codepaths in my fixer for removing extra parens.
I found that after 1.5.0, `if(x())` fixing failed because it removes the parens first, then adds the space. It generates `ifx()` in an intermediate state and is rejected.

The same path works for `with(x())`, removing parens (producing `withx()`) and then adding the space (`with x()`).

This isn't a problem for me, but I think it would be better for these APIs to be as consistent as we can have them! :slightly_smiling_face:

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.