Skip to content

Commit ec01ab3

Browse files
committed
Fix a mypy warning
1 parent c0796a5 commit ec01ab3

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

mypyc/irbuild/ll_builder.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,24 +1419,21 @@ def dunder_op(self, lreg: Value, rreg: Value | None, op: str, line: int) -> Valu
14191419
if not isinstance(ltype, RInstance):
14201420
return None
14211421

1422-
is_binary = bool(rreg)
1423-
method_name = op_methods.get(op) if is_binary else unary_op_methods.get(op)
1422+
method_name = op_methods.get(op) if rreg else unary_op_methods.get(op)
14241423
if method_name is None:
14251424
return None
14261425

14271426
if not ltype.class_ir.has_method(method_name):
14281427
return None
14291428

14301429
decl = ltype.class_ir.method_decl(method_name)
1431-
if not is_binary and len(decl.sig.args) != 1:
1430+
if not rreg and len(decl.sig.args) != 1:
14321431
return None
14331432

1434-
if is_binary and (
1435-
len(decl.sig.args) != 2 or not is_subtype(rreg.type, decl.sig.args[1].type)
1436-
):
1433+
if rreg and (len(decl.sig.args) != 2 or not is_subtype(rreg.type, decl.sig.args[1].type)):
14371434
return None
14381435

1439-
if is_binary and is_subtype(not_implemented_op.type, decl.sig.ret_type):
1436+
if rreg and is_subtype(not_implemented_op.type, decl.sig.ret_type):
14401437
# If the method is able to return NotImplemented, we should not optimize it.
14411438
# We can just let go so it will be handled through the python api.
14421439
return None

0 commit comments

Comments
 (0)