Skip to content

Commit 84f705a

Browse files
committed
feat: better folding
1 parent 4be31c6 commit 84f705a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mypy/constant_fold.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def constant_fold_expr(expr: Expression, cur_mod_id: str) -> ConstantValue | Non
8181
elif (
8282
isinstance(expr, CallExpr)
8383
and isinstance(callee := expr.callee, MemberExpr)
84-
and isinstance(callee.expr, StrExpr)
84+
and isinstance(folded_callee := constant_fold_expr(callee.expr, cur_mod_id), str)
8585
and callee.name == "join"
8686
and len(args := expr.args) == 1
8787
and isinstance(arg := args[0], (ListExpr, TupleExpr))
@@ -92,7 +92,7 @@ def constant_fold_expr(expr: Expression, cur_mod_id: str) -> ConstantValue | Non
9292
if not isinstance(val, str):
9393
return None
9494
folded_items.append(val)
95-
return callee.expr.value.join(folded_items)
95+
return folded_callee.join(folded_items)
9696
return None
9797

9898

0 commit comments

Comments
 (0)