Skip to content

Commit

Permalink
Preserve format string conversion when inlining
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsbuwen committed Sep 3, 2024
1 parent 1fa153c commit bda3dc1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mypy/checkstrformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ def inline_semi_dynamic_specs(
) # dynamic spec cannot be last, this should have been detected earlier

if isinstance(next_expression, StrExpr): # now inline the literal
parsed = parse_format_value(f"{{:{next_expression.value}}}", call, self.msg)
new_format_string = f"{{{spec.conversion or ''}:{next_expression.value}}}"
parsed = parse_format_value(new_format_string, call, self.msg)
if parsed is None or len(parsed) != 1:
continue
spec = parsed[0]
Expand Down

0 comments on commit bda3dc1

Please sign in to comment.