B028 gives wrong suggestion if variable is not a string
xqt opened this issue · comments
B028 gives wrong suggestion if variable is not a string, for example let's have
>>> x = 5
>>> print(f'"{x}"')
"5"
but the representation does not include quotes:
>>> print(f'{x!r}')
5
You have to change the type first like:
>>> print(f'{str(x)!r}')
'5'
but is this an improvement? And the B028 does not suggest this.
See also inducer/pytools#171
Hm, yeah this is probably not an acceptable level of false-positives for a default-on check - thought I'd checked for this in the test but I very much did not. The only way to get around this is to do type analysis on the variable - which becomes quite expensive/complicated for a pretty niche check. @Zac-HD
Per #331 (comment), let's disable it by default.