diff options
| author | Yury Gribov <tetra2005@gmail.com> | 2018-09-01 19:58:11 +0100 |
|---|---|---|
| committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-09-04 10:41:57 +0200 |
| commit | ba62048e04fbe0e691cfccaf173c4ccbccca2992 (patch) | |
| tree | 06464a0015da095fd1b3d724c92985b4b5fb0590 /pylint/checkers/utils.py | |
| parent | c00e464f9536dc3599f476a4fdcb23d832d7673b (diff) | |
| download | pylint-git-ba62048e04fbe0e691cfccaf173c4ccbccca2992.tar.gz | |
Added checker for format string type mismatches.
Diffstat (limited to 'pylint/checkers/utils.py')
| -rw-r--r-- | pylint/checkers/utils.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index 8ac9b1cce..b98941205 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -352,13 +352,16 @@ class UnsupportedFormatCharacter(Exception): Exception.__init__(self, index) self.index = index -def parse_format_string(format_string: str) -> Tuple[Set[str], int]: +def parse_format_string(format_string: str) -> \ + Tuple[Set[str], int, Dict[str, str], List[str]]: """Parses a format string, returning a tuple of (keys, num_args), where keys is the set of mapping keys in the format string, and num_args is the number of arguments required by the format string. Raises IncompleteFormatString or UnsupportedFormatCharacter if a parse error occurs.""" keys = set() + key_types = dict() + pos_types = [] num_args = 0 def next_char(i): i += 1 @@ -416,10 +419,12 @@ def parse_format_string(format_string: str) -> Tuple[Set[str], int]: raise UnsupportedFormatCharacter(i) if key: keys.add(key) + key_types[key] = char elif char != '%': num_args += 1 + pos_types.append(char) i += 1 - return keys, num_args + return keys, num_args, key_types, pos_types def is_attr_protected(attrname: str) -> bool: |
