-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with whitespace_after_*
not fixable
#1118
Comments
Seems like duplicate of #1095 |
@AryazE I had a similar issue. However, the LibCST validator is working correctly here by preventing me from generating incorrect code. I fixed my code and might help you if you share what are you trying to do. I guess you did the same mistake by adding a new node without parentheses. LibCST does not automatically add whitespace or parentheses for you. Here is what I did: just copied the parentheses from the node I was trying to replace: return new_node.with_changes(
lpar=updated_node.lpar,
rpar=updated_node.rpar
) |
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 thevisit_Assert
hook, as the objectnode
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?
The text was updated successfully, but these errors were encountered: