CodeQL documentation

Unsupported format character

ID: py/percent-format/unsupported-character
Kind: problem
Security severity: 
Severity: error
Precision: high
   - reliability
   - correctness
Query suites:
   - python-security-and-quality.qls

Click to see the query in the CodeQL repository

A format string, that is the string on the left hand side of an expression like fmt % arguments, must consist of legal conversion specifiers. Otherwise, a ValueError will be raised.


Choose a legal conversion specifier.


In format_as_tuple_incorrect, “t” is not a legal conversion specifier.

def format_as_tuple_incorrect(args):
    return "%t" % args

def format_as_tuple_correct(args):
    return "%r" % (args,)


  • © GitHub, Inc.
  • Terms
  • Privacy