Uh oh!
There was an error while loading. Please reload this page.
bpo-28002: Roundtrip f-strings with ast.unparse better - #19612
Conversation
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.
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 |
@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 <isidentical@gmail.com>
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.
@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. |
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? |
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.
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 <hauntsaninja@users.noreply.github.com> Co-authored-by: Batuhan Taskaya <isidentical@gmail.com> (cherry picked from commit a993e90) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
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 <hauntsaninja@users.noreply.github.com> Co-authored-by: Batuhan Taskaya <isidentical@gmail.com> (cherry picked from commit a993e90) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
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 <hauntsaninja@users.noreply.github.com> Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
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