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

bpo-35224: Add support for NamedExpr to unparse.py #11670

Merged
merged 1 commit into from Jan 25, 2019

Conversation

@vstinner
Copy link
Member

commented Jan 25, 2019

@vstinner vstinner force-pushed the vstinner:unparse_named_expr branch from bfd824c to cc14c75 Jan 25, 2019

@vstinner

This comment has been minimized.

Copy link
Member Author

commented Jan 25, 2019

Oh, my first attempt without parenthesis failed: "(x := 1)" became "x := 1" which raises a SyntaxError. I modified my PR to always add parenthesis.

I will push this change to repair buildbots. If someone finds a smarter solution to omit parenthesis in some cases, please go ahead. I never used unparse.py. I don't think that it should nor that it can produce exactly the same input file, since Python looses many formatting information with code is compiled to bytecode (or even just when compiled to AST).

@vstinner

This comment has been minimized.

Copy link
Member Author

commented Jan 25, 2019

I tested manually on Linux: " ./python -m test test_tools -u all -v" pass with success.

@tirkarthi

This comment has been minimized.

Copy link
Contributor

commented Jan 25, 2019

cc @emilyemorehouse

@vstinner

This comment has been minimized.

Copy link
Member Author

commented Jan 25, 2019

Example:

vstinner@apu$ cat x.py 
str(x := 1)
str(y:=2)
(z:=3)

vstinner@apu$ ./python Tools/parser/unparse.py x.py 

str((x := 1))
str((y := 2))
(z := 3)

There are useless parentheses, but as I wrote, it's hard to emit the perfect code only from AST. And I wrote a quick fix to repair the CI ;-)

@vstinner vstinner merged commit 1396d8f into python:master Jan 25, 2019

4 of 5 checks passed

Azure Pipelines PR in progress
Details
bedevere/issue-number Issue number 35224 found
Details
bedevere/news "skip news" label found
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@vstinner vstinner deleted the vstinner:unparse_named_expr branch Jan 25, 2019

animalize added a commit to animalize/cpython that referenced this pull request Jan 30, 2019
arnolddumas added a commit to arnolddumas/cpython that referenced this pull request May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.