(self, left: Overloaded)
| 986 | return self._is_subtype(left.fallback, self.right) |
| 987 | |
| 988 | def visit_overloaded(self, left: Overloaded) -> bool: |
| 989 | right = self.right |
| 990 | if isinstance(right, Instance): |
| 991 | if right.type.is_protocol and "__call__" in right.type.protocol_members: |
| 992 | # same as for CallableType |
| 993 | call = find_member("__call__", right, right, is_operator=True) |
| 994 | assert call is not None |
| 995 | if self._is_subtype(left, call): |
| 996 | if len(right.type.protocol_members) == 1: |
| 997 | return True |
| 998 | if is_protocol_implementation(left.fallback, right, skip=["__call__"]): |
| 999 | return True |
| 1000 | return self._is_subtype(left.fallback, right) |
| 1001 | elif isinstance(right, CallableType): |
| 1002 | for item in left.items: |
| 1003 | if self._is_subtype(item, right): |
| 1004 | return True |
| 1005 | return False |
| 1006 | elif isinstance(right, Overloaded): |
| 1007 | if left == self.right: |
| 1008 | # When it is the same overload, then the types are equal. |
| 1009 | return True |
| 1010 | |
| 1011 | # Ensure each overload on the right side (the supertype) is accounted for. |
| 1012 | previous_match_left_index = -1 |
| 1013 | matched_overloads = set() |
| 1014 | |
| 1015 | for right_item in right.items: |
| 1016 | found_match = False |
| 1017 | |
| 1018 | for left_index, left_item in enumerate(left.items): |
| 1019 | subtype_match = self._is_subtype(left_item, right_item) |
| 1020 | |
| 1021 | # Order matters: we need to make sure that the index of |
| 1022 | # this item is at least the index of the previous one. |
| 1023 | if subtype_match and previous_match_left_index <= left_index: |
| 1024 | previous_match_left_index = left_index |
| 1025 | found_match = True |
| 1026 | matched_overloads.add(left_index) |
| 1027 | break |
| 1028 | else: |
| 1029 | # If this one overlaps with the supertype in any way, but it wasn't |
| 1030 | # an exact match, then it's a potential error. |
| 1031 | strict_concat = ( |
| 1032 | (self.options.extra_checks or self.options.strict_concatenate) |
| 1033 | if self.options |
| 1034 | else False |
| 1035 | ) |
| 1036 | if left_index not in matched_overloads and ( |
| 1037 | is_callable_compatible( |
| 1038 | left_item, |
| 1039 | right_item, |
| 1040 | is_compat=self._is_subtype, |
| 1041 | is_proper_subtype=self.proper_subtype, |
| 1042 | ignore_return=True, |
| 1043 | ignore_pos_arg_names=self.subtype_context.ignore_pos_arg_names, |
| 1044 | strict_concatenate=strict_concat, |
| 1045 | ) |
nothing calls this directly
no test coverage detected