diff --git a/mypy/checkstrformat.py b/mypy/checkstrformat.py index 0ff81fb1ea58..0ddcd9d2d194 100644 --- a/mypy/checkstrformat.py +++ b/mypy/checkstrformat.py @@ -81,7 +81,9 @@ def parse_conversion_specifiers(self, format: str) -> List[ConversionSpecifier]: for parens_key, key, flags, width, precision, type in re.findall(regex, format): if parens_key == '': key = None - specifiers.append(ConversionSpecifier(key, flags, width, precision, type)) + specifier = ConversionSpecifier(key, flags, width, precision, type) + if specifier.type != '%' or specifier.has_star(): + specifiers.append(specifier) return specifiers def analyze_conversion_specifiers(self, specifiers: List[ConversionSpecifier], diff --git a/test-data/unit/check-expressions.test b/test-data/unit/check-expressions.test index e80de39763d6..8fbcaefd4ba9 100644 --- a/test-data/unit/check-expressions.test +++ b/test-data/unit/check-expressions.test @@ -989,6 +989,8 @@ a = None # type: Any '%()d' % {'': 2} '%(a)d' % {'a': 1, 'b': 2, 'c': 3} '%(q)d' % {'a': 1, 'b': 2, 'c': 3} # E: Key 'q' not found in mapping +'%(a)d %%' % {'a': 1} + [builtins fixtures/dict.py] [case testStringInterpolationMappingDictTypes]