Skip to content

Commit 417fa73

Browse files
Update specialize.py
1 parent e71e215 commit 417fa73

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

mypyc/irbuild/specialize.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -711,20 +711,18 @@ def translate_fstring(builder: IRBuilder, expr: CallExpr, callee: RefExpr) -> Va
711711
format_ops.append(FormatOp.STR)
712712
exprs.append(item.args[0])
713713

714+
def get_literal_str(expr: Expression) -> str | None:
715+
if isinstance(expr, StrExpr):
716+
return expr.value
717+
elif (
718+
isinstance(expr, RefExpr)
719+
and isinstance(expr.node, Var)
720+
and expr.node.final_value is not None
721+
):
722+
return str(expr.node.final_value)
723+
return None
724+
714725
for i in range(len(exprs) - 1):
715-
716-
def get_literal_str(expr: Expression) -> str | None:
717-
# NOTE: not sure where I should put this helper, this file? somewhere else?
718-
if isinstance(expr, StrExpr):
719-
return expr.value
720-
elif (
721-
isinstance(expr, RefExpr)
722-
and isinstance(expr.node, Var)
723-
and expr.node.final_value is not None
724-
):
725-
return str(expr.node.final_value)
726-
return None
727-
728726
while (
729727
len(exprs) >= i + 2
730728
and (first := get_literal_str(exprs[i])) is not None

0 commit comments

Comments
 (0)