Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions mypy/checkstrformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test-data/unit/check-errorcodes.test
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
Loading