-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Consider quotes inside format-specs when choosing the quotes for an f-string #14493
base: main
Are you sure you want to change the base?
Conversation
68ca92e
to
f681076
Compare
|
Hmm, this now leads to invalid syntax for |
Okay, this is a pre-existing issue, but not one that gets fixed by this PR. f'{1=: "abcd {'aa'} \'\'}' We can't change the outer quotes because the format-spec quotes then become the "closing" quotes of the entire-fstring (which they shouldn't). That means we have to preserve the quotes if:
|
I'll do another review myself of the code changes with a fresh mind tomorrow morning but I think this is mostly correct. |
let quote = if let Some(quote) = preserve_quotes_requirement { | ||
quote |
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.
The only change here is the addition of this condition to return the quote that needs to be preserved? I'm curious to know why was this condition not present before this? It seems like it should've been present.
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.
Not 100%. I would have to remind myself of how the pre 312 fstring formatting works again. It might also just be that we were missing a test.
Summary
Fixes #13935
Test Plan
Added test