Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.1k
Fix and optimise overload compatibility checking#14018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -823,9 +823,8 @@ def visit_overloaded(self, left: Overloaded) -> bool: | ||
| # Ensure each overload in the right side (the supertype) is accounted for. | ||
| previous_match_left_index = -1 | ||
| matched_overloads = set() | ||
| for right_item in right.items: | ||
| found_match = False | ||
| for left_index, left_item in enumerate(left.items): | ||
| @@ -834,44 +833,36 @@ def visit_overloaded(self, left: Overloaded) -> bool: | ||
| # Order matters: we need to make sure that the index of | ||
| # this item is at least the index of the previous one. | ||
| if subtype_match and previous_match_left_index <= left_index: | ||
| previous_match_left_index = left_index | ||
| found_match = True | ||
| matched_overloads.add(left_index) | ||
| break | ||
CollaboratorAuthor
| ||
| else: | ||
| # If this one overlaps with the supertype in any way, but it wasn't | ||
| # an exact match, then it's a potential error. | ||
| strict_concat = self.options.strict_concatenate if self.options else True | ||
| if left_index not in matched_overloads and ( | ||
| is_callable_compatible( | ||
| left_item, | ||
| right_item, | ||
| is_compat=self._is_subtype, | ||
| ignore_return=True, | ||
| ignore_pos_arg_names=self.subtype_context.ignore_pos_arg_names, | ||
| strict_concatenate=strict_concat, | ||
| ) | ||
| or is_callable_compatible( | ||
| right_item, | ||
| left_item, | ||
| is_compat=self._is_subtype, | ||
| ignore_return=True, | ||
| ignore_pos_arg_names=self.subtype_context.ignore_pos_arg_names, | ||
| strict_concatenate=strict_concat, | ||
| ) | ||
| ): | ||
| return False | ||
| if not found_match: | ||
| return False | ||
| return True | ||
| elif isinstance(right, UnboundType): | ||
| return True | ||