Checker for string formatting operations.
Class |
|
Check string literals. |
Class |
|
Checks string formatting operations to ensure that the format string is valid and the arguments match the format string. |
Function | arg |
Undocumented |
Function | get |
Given a list of format specifiers, returns the final access path (e.g. a.b.c[0][1]). |
Function | register |
Undocumented |
Function | str |
Mostly replicate `ast.literal_eval(token)` manually to avoid any performance hit. |
Constant | DOUBLE |
Undocumented |
Constant | MSGS |
Undocumented |
Constant | OTHER |
Undocumented |
Constant | QUOTE |
Undocumented |
Constant | SINGLE |
Undocumented |
Function | _get |
Returns the quote character used to delimit this token string. |
Function | _is |
Is this string token a "longstring" (is it triple-quoted)? |
Function | _is |
Was there a non-awkward option for the quote delimiter? |
Constant | _AST |
Undocumented |
Constant | _PREFIXES |
Undocumented |
SuccessfulInferenceResult
, format_type: str
) -> bool
:
(source)
¶
Undocumented
Mostly replicate `ast.literal_eval(token)` manually to avoid any performance hit. This supports f-strings, contrary to `ast.literal_eval`. We have to support all string literal notations: https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals
Undocumented
Value |
|
Undocumented
Value |
|
Returns the quote character used to delimit this token string. This function checks whether the token is a well-formed string. Args: string_token: The token to be parsed. Returns: A string containing solely the first quote delimiter character in the given string. Raises: ValueError: No quote delimiter characters are present.
Is this string token a "longstring" (is it triple-quoted)? Long strings are triple-quoted as defined in https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals This function only checks characters up through the open quotes. Because it's meant to be applied only to tokens that represent string literals, it doesn't bother to check for close-quotes (demonstrating that the literal is a well-formed string). Args: string_token: The string token to be parsed. Returns: A boolean representing whether this token matches a longstring regex.
Was there a non-awkward option for the quote delimiter? Args: string_token: The quoted string whose delimiters are to be checked. Returns: Whether there was a choice in this token's quote character that would not have involved backslash-escaping an interior quote character. Long strings are excepted from this analysis under the assumption that their quote characters are set by policy.