QUERY · ISSUE
Spaces in f-strings can cause incorrect SyntaxErrors
py-core
Here are two examples of valid f-strings that currently raise SyntaxErrors:
>>> x = 10
>>> f"{x = }"
SyntaxError: invalid syntax
>>> f"{x = :.3f}"
SyntaxError: invalid syntax
Removing the spaces between the curlies is the recommended workaround.
(The examples were found when browsing Python f-strings Are More Powerful Than You Might Think)
These issues should either be documented (in cpydiff) or resolved.
To resolve, see the comment in https://github.com/micropython/micropython/commit/692d36d779192f32371f7f9daa845b566f26968d for background. A solution may be possible by modifying the lexer to strip spaces from the f-string before translating it to str.format.
CANDIDATE · ISSUE
f-string feature missing on esp8266 with 1MiB flash port, throws SyntaxError: invalid syntax
port-esp8266
Code example:
string = "F-STRING"
print(f"{string} OK")
see: https://github.com/micropython/micropython/releases/tag/v1.18
...
esp8266 port:
- boards/GENERIC: enable f-strings
...
...