This is a bug in pylint ; he assumes that all string formats are byte strings.
Linter parses the format and then the placeholder names. Since you use Unicode literals, this also creates a unicode name, but the parser makes the assumption that it will only encounter bittests; if not, he assumes he will find an integer:
if not isinstance(keyname, str):
This results in a ValueError for your format string, since world parsed for unicode value:
>>> import string >>> formatter = string.Formatter() >>> parseiterator = formatter.parse(u'hello {world}') >>> result = next(parseiterator) >>> result (u'hello ', u'world', u'', None) >>> keyname, fielditerator = result[1]._formatter_field_name_split() >>> keyname u'world'
The ValueError exception, in turn, is caught and converted to an IncompleteFormatString exception, which then leads to error W1302 .
See the parse_format_method_string function.
The test there must be modified to check the same type as format_string :
if not isinstance(keyname, type(format_string)):
This will do the right thing in both Python 2 and 3.
source share