Skip to content

Commit ad58850

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 712b10a commit ad58850

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

mypyc/irbuild/specialize.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -714,16 +714,27 @@ def translate_fstring(builder: IRBuilder, expr: CallExpr, callee: RefExpr) -> Va
714714
for i in range(len(exprs) - 1):
715715
# NOTE: not sure where I should put these helpers
716716
def is_literal_str(expr: Expression) -> bool:
717-
return isinstance(expr, StrExpr) or isinstance(expr, RefExpr) and isinstance(expr.node, Var) and expr.node.final_value is not None
718-
717+
return (
718+
isinstance(expr, StrExpr)
719+
or isinstance(expr, RefExpr)
720+
and isinstance(expr.node, Var)
721+
and expr.node.final_value is not None
722+
)
723+
719724
def get_literal_str(expr: Expression) -> str | None:
720725
if isinstance(expr, StrExpr):
721726
return expr.value
722-
elif isinstance(expr, RefExpr) and isinstance(expr.node, Var) and expr.node.final_value is not None:
727+
elif (
728+
isinstance(expr, RefExpr)
729+
and isinstance(expr.node, Var)
730+
and expr.node.final_value is not None
731+
):
723732
return str(expr.node.final_value)
724733
return None
725-
726-
while len(exprs) >= i + 2 and is_literal_str(exprs[i]) and is_literal_str(exprs[i + 1]):
734+
735+
while (
736+
len(exprs) >= i + 2 and is_literal_str(exprs[i]) and is_literal_str(exprs[i + 1])
737+
):
727738
first = exprs[i]
728739
concatenated = StrExpr(get_literal_str(first) + get_literal_str(exprs[i + 1])) # type: ignore [operator]
729740
exprs = [*exprs[:i], concatenated, *exprs[i + 2 :]]

0 commit comments

Comments
 (0)