Skip to content

gh-141271: fix f/t-str set expr quotes and nested comments#141274

Open
tom-pytel wants to merge 4 commits intopython:mainfrom
tom-pytel:fix-issue-141271
Open

gh-141271: fix f/t-str set expr quotes and nested comments#141274
tom-pytel wants to merge 4 commits intopython:mainfrom
tom-pytel:fix-issue-141271

Conversation

@tom-pytel
Copy link
Copy Markdown
Contributor

@tom-pytel tom-pytel commented Nov 8, 2025

Fix more complex cases of f/t-string quotes and nested f/t-strings. This is initial quick job so there is chance I missed something so please have a good look.

Question remaining, should the comments of NESTED f/t-strings show up in the parent f/t-string expression or not. In other words, should the following:

>>> print(f'{ # comment A
... (f'''
... # not comment B
... { # comment C '
... 3 # comment D
... * 2}''', '\n# not comment E\n6')=}')

Evaluate to:

(f'''
# not comment B
{ 
3 
* 2}''', '\n# not comment E\n6')=('\n# not comment B\n6', '\n# not comment E\n6')

Or (parent # comment A stripped, nested comments left):

(f'''
# not comment B
{ # comment C '
3 # comment D
* 2}''', '\n# not comment E\n6')=('\n# not comment B\n6', '\n# not comment E\n6')

Currently is first case, all stripped.

@tom-pytel
Copy link
Copy Markdown
Contributor Author

Ping @pablogsal, @lysnikolaou

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants