diff --git a/mypy/checkstrformat.py b/mypy/checkstrformat.py index 289961523b1d..09758e7d990a 100644 --- a/mypy/checkstrformat.py +++ b/mypy/checkstrformat.py @@ -1073,6 +1073,15 @@ def conversion_type( return UnionType( [self.named_type("builtins.int"), self.named_type("builtins.str")] ) + elif p.startswith(("<", ">", "=", "^")): + # THIS CODE IS WRONG + return UnionType( + [ + self.named_type("builtins.int"), + self.named_type("builtins.float"), + self.named_type("builtins.str"), + ] + ) else: self.msg.unsupported_placeholder(p, context) return None diff --git a/test-data/unit/check-errorcodes.test b/test-data/unit/check-errorcodes.test index 6ec246fb3a13..aeb15bd66ef4 100644 --- a/test-data/unit/check-errorcodes.test +++ b/test-data/unit/check-errorcodes.test @@ -645,6 +645,8 @@ def g() -> int: '{}'.format(b'abc') # E: If x = b'abc' then f"{x}" or "{}".format(x) produces "b'abc'", not "abc". If this is desired behavior, use f"{x!r}" or "{!r}".format(x). Otherwise, decode the bytes [str-bytes-safe] '%s' % b'abc' # E: If x = b'abc' then "%s" % x produces "b'abc'", not "abc". If this is desired behavior use "%r" % x. Otherwise, decode the bytes [str-bytes-safe] +'{:>2}'.format(None) # E: alignment format specs are not supported on NoneType [str-format] + [builtins fixtures/primitives.pyi] [typing fixtures/typing-medium.pyi]