Skip to content

Commit 2040599

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

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

mypy/constant_fold.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,20 +216,23 @@ def constant_fold_unary_op(op: str, value: ConstantValue) -> int | float | None:
216216
"builtins.chr": chr,
217217
}
218218

219-
def constant_fold_call_expr(expr: CallExpr, cur_mod_id: str, foldable_builtins=foldable_builtins) -> ConstantValue | None:
219+
220+
def constant_fold_call_expr(
221+
expr: CallExpr, cur_mod_id: str, foldable_builtins=foldable_builtins
222+
) -> ConstantValue | None:
220223
callee = expr.callee
221224
if isinstance(callee, NameExpr):
222225
func = foldable_builtins.get(callee.fullname)
223226
if func is None:
224227
return None
225-
228+
226229
folded_args = []
227230
for arg in expr.args:
228231
val = constant_fold_expr(arg, cur_mod_id)
229232
if val is None:
230233
return None
231234
folded_args.append(arg)
232-
235+
233236
args = []
234237
kwargs = {}
235238
for folded_arg, arg_kind, arg_name in zip(folded_args, expr.arg_kinds, expr.arg_names):
@@ -250,9 +253,8 @@ def constant_fold_call_expr(expr: CallExpr, cur_mod_id: str, foldable_builtins=f
250253
except:
251254
return None
252255
# --- f-string requires partial support for both str.join and str.format ---
253-
elif (
254-
isinstance(callee, MemberExpr)
255-
and isinstance(folded_callee := constant_fold_expr(callee.expr, cur_mod_id), str)
256+
elif isinstance(callee, MemberExpr) and isinstance(
257+
folded_callee := constant_fold_expr(callee.expr, cur_mod_id), str
256258
):
257259
# --- partial str.join constant folding ---
258260
if (
@@ -275,4 +277,4 @@ def constant_fold_call_expr(expr: CallExpr, cur_mod_id: str, foldable_builtins=f
275277
if arg_val is None:
276278
return None
277279
folded_args.append(arg_val)
278-
return folded_callee.format(*folded_args)
280+
return folded_callee.format(*folded_args)

0 commit comments

Comments
 (0)