Instagram / Instagram/LibCST

Issue with `whitespace_after_*` not fixable

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

Description

I have to transform (using a libcst.CSTTransformer) some 3rd party code, which might contain statements like `assert("foo") == "foo"`.
Although this is a valid python code, I get the error `libcst._nodes.base.CSTValidationError: Must have at least one space after 'assert'.`
I cannot fix this in the `leave_Assert` hook, as it is called after validation, and I cannot fix it in the `visit_Assert` hook, as the object `node` is frozen.
Currently, the only option I can think of is to do a regex search and replace before LibCST to add the missing whitespace and then feed it to my transformer.
Is there any easier way to do this, preferably within LibCST?

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.