Consider quotes inside format-specs when choosing the quotes for an f-string#14493
Consider quotes inside format-specs when choosing the quotes for an f-string#14493MichaReiser merged 4 commits intomainfrom
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.
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.
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.
c402856 to
2e3416e
Compare
Summary
Fixes #13935
Test Plan
Added test