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

Allow unparenthesized walrus in set literals, set comprehensions and indexes #162

Merged
merged 1 commit into from
Dec 10, 2020

Conversation

gousaiyang
Copy link
Collaborator

This incorporates two recent changes in CPython upstream:

As for the code change, I cannot directly use namedexpr_test in dictorsetmaker and subscript because that will produce ambiguous rules.

@isidentical isidentical self-requested a review November 28, 2020 01:30
@isidentical
Copy link
Collaborator

I believe it looks fine, thanks @gousaiyang! @davidhalter can you check this out? "The ambiguity arises in"

@davidhalter
Copy link
Owner

Sorry for the delay (was awaiting my firstborn :)), but thanks for the change!

I think this is definitely fine, but I will check why this causes ambiguities.

IMO we will have to find a (PEG) solution for the parser anyway during the next year, so this grammar change is not a problem anyway.

@davidhalter davidhalter merged commit f45ffa1 into davidhalter:master Dec 10, 2020
@isidentical
Copy link
Collaborator

Sorry for the delay (was awaiting my firstborn :)

🚀 Congratulations!

@davidhalter
Copy link
Owner

I just tried to check why the ambiguity problem arises:

subscript: test [':=' test] | [test] ':' [test] [sliceop]
vs.
subscript: namedexpr_test | [test] ':' [test] [sliceop]

The problem in the latter example is that for all the first tokens (e.g. for a lambda token), the LL parser does not know if it should use test or namedexpr_test, because there's an alternative [test].

So this is definitely a limitation of our current parser.

@davidhalter
Copy link
Owner

Also released 0.8.1 with this.

@gousaiyang gousaiyang deleted the walrus-set-and-index branch December 11, 2020 02:22
ichard26 added a commit to psf/black that referenced this pull request Aug 26, 2021
Implementation stolen from PR davidhalter/parso#162. Thanks parso!

I could add support for these newer syntactical constructs in the
target version detection logic, but until I get diff-shades up
and running I don't feel very comfortable adding the code.
JelleZijlstra pushed a commit to psf/black that referenced this pull request Aug 26, 2021
Implementation stolen from PR davidhalter/parso#162. Thanks parso!

I could add support for these newer syntactical constructs in the
target version detection logic, but until I get diff-shades up
and running I don't feel very comfortable adding the code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants