semgrep / pfff

pfff is mainly an OCaml API to write static analysis, dynamic analysis, code visualizations, code navigations, or style-preserving source-to-source transformations such as refactorings on source code.
https://semgrep.dev
Other
186 stars 29 forks source link

fix(python): Allows parens around `with` context exprs #521

Closed kopecs closed 2 years ago

kopecs commented 2 years ago

This PR adds support for parentheses around with context expressions. Previously, we allowed code like:

with open(x) as a, open(y) as b:
    pass

but not

with (open(x) as a, open(y) as b):
    pass

(or with a trailing comma)

After this PR, both would parse correctly.

Helps PA-1218

Test plan: tests included.

Security