Issue 33552: f-strings and string annotations (original) (raw)

Issue33552

Created on 2018-05-17 07:03 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg316886 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-05-17 07:03
There are problems with converting annotations containing f-strings into strings (from __future__ import annotations). For example f'''{"'"}''' is converted to f'{"\'"}', but the latter is a syntax error. >>> from __future__ import annotations >>> x: f'''{"'"}''' >>> print(__annotations__['x']) f'{"\'"}' >>> x: f'{"\'"}' File "", line 1 SyntaxError: f-string expression part cannot include a backslash More complex examples: f"""{"'''"}""" f"""{"'" '"'}""" f"""{"'''"}""" f'''{'"""'}'''
History
Date User Action Args
2022-04-11 14:59:00 admin set github: 77733
2021-10-25 21:44:25 iritkatriel set versions: + Python 3.9, Python 3.10, Python 3.11, - Python 3.7, Python 3.8
2018-05-17 07:03:06 serhiy.storchaka create