Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
bpo-28002: Roundtrip f-strings with ast.unparse better#19612
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
hauntsaninja commented Apr 20, 2020 • edited by miss-islington
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by miss-islington
Uh oh!
There was an error while loading. Please reload this page.
hauntsaninja commented Apr 20, 2020 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Some notes:
cc @isidentical |
hauntsaninja commented Apr 20, 2020
The test failure in test_concurrent_futures on Windows x86 seems unrelated to this PR |
Uh oh!
There was an error while loading. Please reload this page.
hauntsaninja commented Apr 21, 2020 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
One issue with the PR as it stands is the perhaps undesirable unparsing of the following, probably reasonably common f-string: For this to pass a src roundtrip, we'd need to process the buffer a little more intelligently when |
isidentical commented May 20, 2020 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@hauntsaninja would you rebase and (if you liked it) apply the suggestions. So we can move forward, and try to improve it. I have a script that I'll plan to test this PR against top PyPI packages, so we might find more problems / or verify that it works well at the end. |
By attempting to avoid backslashes in f-string expressions. We also now proactively raise errors for some backslashes we can't avoid while unparsing FormattedValues
Co-authored-by: Batuhan Taskaya <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
isidentical commented May 22, 2020
FYI, this patch fails on roundtripping this file https://github.com/numpy/numpy/blob/master/tools/refguide_check.py |
isidentical commented May 22, 2020
What about not including the |
hauntsaninja commented May 22, 2020
Thanks, updated to include your two comments! I think including Let me see if I can come up with a fix over the weekend, otherwise we can go ahead and make the |
isidentical commented Jun 1, 2020
A gentle ping @hauntsaninja |
The previous cosmetic fix means we use triple quotes less often, so this is less likely to occur in practice, but should be fixed anyway.
hauntsaninja commented Jun 3, 2020
Thanks for the reminder! Made changes that should result in better cosmetic unparsing of cases like |
hauntsaninja commented Oct 18, 2020
@isidentical Thanks for taking another look! I made the changes as suggested, except for the ones I replied to |
isidentical left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pablogsal would you mind checking out this?
isidentical commented Oct 18, 2020
Thanks for the continuous work @hauntsaninja! If you have time, please try the latest version on the most downloaded PyPI packages set, if not please let me know (so I can test it by myself). |
isidentical commented Oct 18, 2020
Also, you should be able to collapse my reviews (mark them as resolved) so that it won't distract people when reading the history. |
hauntsaninja commented Oct 18, 2020 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
The CI failure here looks like a flake. I re-ran AST roundtripping over 4k packages and everything was clear (apart from some pre-existing RecursionErrors) |
isidentical commented Nov 12, 2020
A gentle ping @ericvsmith. Do you plan to take a look? |
hauntsaninja commented Nov 20, 2020 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
I'd love for this to make 3.9.1, if possible! :-) |
isidentical commented Nov 20, 2020
closing and re-opening for the CI |
ericvsmith left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay. This looks reasonable enough to me, but someone who's more familiar with the AST and/or unparsing should take a look. Maybe @ambv?
isidentical commented Nov 20, 2020
re-triggering the CI (some irrelevant macos failure) |
bedevere-bot commented Nov 20, 2020
@isidentical: Please replace |
miss-islington commented Nov 20, 2020
Thanks @hauntsaninja for the PR, and @isidentical for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
By attempting to avoid backslashes in f-string expressions. We also now proactively raise errors for some backslashes we can't avoid while unparsing FormattedValues Co-authored-by: hauntsaninja <> Co-authored-by: Shantanu <[email protected]> Co-authored-by: Batuhan Taskaya <[email protected]> (cherry picked from commit a993e90) Co-authored-by: Shantanu <[email protected]>
bedevere-bot commented Nov 20, 2020
GH-23430 is a backport of this pull request to the 3.9 branch. |
…-23430) By attempting to avoid backslashes in f-string expressions. We also now proactively raise errors for some backslashes we can't avoid while unparsing FormattedValues Co-authored-by: hauntsaninja <> Co-authored-by: Shantanu <[email protected]> Co-authored-by: Batuhan Taskaya <[email protected]> (cherry picked from commit a993e90) Co-authored-by: Shantanu <[email protected]> Co-authored-by: Shantanu <[email protected]>
isidentical commented Nov 20, 2020
Thank you so much for your continuous efforts on this issue @hauntsaninja. |
hauntsaninja commented Nov 20, 2020
Thank you for making this PR happen! :-) |
By attempting to avoid backslashes in f-string expressions. We also now proactively raise errors for some backslashes we can't avoid while unparsing FormattedValues Co-authored-by: hauntsaninja <> Co-authored-by: Shantanu <[email protected]> Co-authored-by: Batuhan Taskaya <[email protected]>
By attempting to avoid backslashes in f-string expressions.
We also now proactively raise errors for some backslashes we can't
avoid while unparsing FormattedValues
https://bugs.python.org/issue28002
Automerge-Triggered-By: GH:isidentical