-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
t-strings: AST unparsing does not reproduce original formatting #133581
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
Comments
This leads to AST roundtrip failures (showing up in test cases in #133553). |
cc @lysnikolaou |
Hmm, what exactly is failing in the AST roundtrip tests? |
The AST changes on roundtrip because the AST for an interpolation object includes the raw text, which changes. |
Oh right, I hit that while working on the PEP PR and thought I'd implemented skipping checking Not sure whether we should be using it for |
Because in t-strings the original source code is part of the AST, and in the rest of the grammar it isn't. In general I feel |
(cherry picked from commit bfac7d2) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit 308ceff) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This has been fixed. |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
The AST unparsing of
Interpolation
objects does not reproduce formatting within interpolations.This is true both for
ast.unparse
in Python:And for the C unparse that is used by
from __future__ import annotations
:In general, we can't recover the original source exactly, but in this case we do have the original source available:
Let's use it.
CPython versions tested on:
3.14
Operating systems tested on:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: