Skip to content

Commit be85cef

Browse files
improved comments
1 parent 450b043 commit be85cef

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

mypy/checkexpr.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4049,18 +4049,19 @@ def lookup_definer(typ: Instance, attr_name: str) -> str | None:
40494049

40504050
variants_raw = [(op_name, left_op, left_type, right_expr)]
40514051
elif (
4052-
# Note: use covers_at_runtime instead of is_subtype.
4053-
# fixes https://github.com/python/mypy/issues/19006
4052+
# Note: use `covers_at_runtime` instead of `is_subtype` (#19006)
40544053
covers_at_runtime(right_type, left_type)
40554054
and (
4055+
# Checking (A implies B) using the logically equivalent (not A or B), where
4056+
# A: left and right are both `Instance` objects
4057+
# B: right's __rop__ method is different from left's __op__ method
40564058
not (isinstance(left_type, Instance) and isinstance(right_type, Instance))
40574059
or (
4058-
(
4060+
lookup_definer(left_type, op_name) != lookup_definer(right_type, rev_op_name)
4061+
and (
40594062
left_type.type.alt_promote is None
40604063
or left_type.type.alt_promote.type is not right_type.type
40614064
)
4062-
and lookup_definer(left_type, op_name)
4063-
!= lookup_definer(right_type, rev_op_name)
40644065
)
40654066
)
40664067
):

test-data/unit/check-expressions.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,8 @@ class B:
681681
s: str
682682
s = A() + B() # E: Unsupported operand types for + ("A" and "B")
683683

684-
[case testReverseBinaryOperator4]
685684

685+
[case testReverseBinaryOperator4]
686686
from typing import assert_type, Never
687687

688688
class Size(tuple[int, ...]):

0 commit comments

Comments
 (0)