Skip to content
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

Support PEP-614 - relaxed grammar restrictions on decorators #486

Closed
Zac-HD opened this issue May 20, 2021 · 2 comments
Closed

Support PEP-614 - relaxed grammar restrictions on decorators #486

Zac-HD opened this issue May 20, 2021 · 2 comments
Labels
enhancement New feature or request parsing Converting source code into CST nodes

Comments

@Zac-HD
Copy link
Contributor

Zac-HD commented May 20, 2021

Following PEP-614, the follow code is valid in Python 3.9 and later:

@(lambda f: f)  # or other expressions, e.g. `@buttons[0].clicked.connect`
def valid_on_py39():
    pass

but libcst.parse_module() raises

Traceback (most recent call last):
  ...
libcst._exceptions.ParserSyntaxError: Syntax Error @ 1:2.
Incomplete input. Encountered '(', but expected 'NAME'.

@(lambda f: f)
 ^

This syntax isn't in common use yet, but shed depends on LibCST for --refactor mode and I'd love to support it 😃

@zsol
Copy link
Member

zsol commented Jun 16, 2022

So this is already supported by the native parser (currently enabled by setting the LIBCST_PARSER_TYPE env var to native), but validation rules on the CST nodes disallow it. Needs a PR to relax the validation rules before this issue can be closed out

@zsol zsol added the parsing Converting source code into CST nodes label Jun 16, 2022
@Zac-HD
Copy link
Contributor Author

Zac-HD commented May 26, 2023

Closed by #926 and fixed in version 0.4.10 🎉

@Zac-HD Zac-HD closed this as completed May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request parsing Converting source code into CST nodes
Projects
None yet
Development

No branches or pull requests

2 participants