Skip to content

Commit bda3dc1

Browse files
committed
Preserve format string conversion when inlining
1 parent 1fa153c commit bda3dc1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

mypy/checkstrformat.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ def inline_semi_dynamic_specs(
391391
) # dynamic spec cannot be last, this should have been detected earlier
392392

393393
if isinstance(next_expression, StrExpr): # now inline the literal
394-
parsed = parse_format_value(f"{{:{next_expression.value}}}", call, self.msg)
394+
new_format_string = f"{{{spec.conversion or ''}:{next_expression.value}}}"
395+
parsed = parse_format_value(new_format_string, call, self.msg)
395396
if parsed is None or len(parsed) != 1:
396397
continue
397398
spec = parsed[0]

0 commit comments

Comments
 (0)