Open
Description
pyflakes does some format specifier checks (#443), but it isn't able to detect invalid format specifiers. For example
f"{x:f.1}"
"{x:f.1}".format(x=1)
are both wrong (the f
is supposed to go after the .1
). Also the f-string one is a ValueError and is only checked at runtime.
The format specification mini-language is pretty complicated, so this would be useful, but also maybe not easy to implement. For .format
strings you can use https://docs.python.org/3/library/string.html#string.Formatter.parse, but for f-strings, there's nothing in the standard library that can tokenize the f-string components (it would be useful if there were). Libraries like pygments and parso can tokenize them, or maybe the tokenizer added in #443 can be extended to handle them.
Metadata
Metadata
Assignees
Labels
No labels