-
Notifications
You must be signed in to change notification settings - Fork 108
Description
I've seen some code lately where a reminder about the !r
format specifier would probably have helped - instead of displaying the repr, single-quotes were manually added outside the braces as in f"No value found at '{path}'"
. This OK, until path
contains a single-quote character and then it can get confusing fast.
I'd therefore propose warning about this case, which is conveniently easy to reliably detect using the JoinedStr
and FormattedValue
nodes - within a JoinedStr
, warn if there is a sequence of Constant
/FormattedValue
/Constant
, where the first constant ends and the second starts with a single or double quote character, and the formatter value has no conversion code.
Separately, I used the regex ".*('\{[^}]+\}').*"
to confirm that this is common enough to be worth linting for. It's not especially rare, and IMO pretty useful to teach people about format specifiers.