Skip to content

Commit d30b2b5

Browse files
Update checkstrformat.py
1 parent 30d454d commit d30b2b5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mypy/checkstrformat.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,11 +1008,11 @@ def check_expr(expr: Expression) -> None:
10081008
self.msg.requires_int_or_single_byte(context)
10091009
else:
10101010
if isinstance(folded := constant_fold_expr(expr, "unused"), str):
1011-
value = folded
1011+
if len(folded) != 1:
1012+
self.msg.requires_int_or_char(context)
10121013
elif isinstance(expr, BytesExpr):
1013-
value = expr.value
1014-
if len(value) != 1:
1015-
self.msg.requires_int_or_char(context)
1014+
if len(expr.value) != 1:
1015+
self.msg.requires_int_or_char(context)
10161016

10171017
return check_expr, check_type
10181018

0 commit comments

Comments
 (0)