Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overload overlap check for UninhabitedType #13461

Merged
merged 3 commits into from
Aug 21, 2022

Conversation

ilevkivskyi
Copy link
Member

The issue was exposed by merge of subtype visitors. Fix is actually trivial, but the diff is big because I need to add and pass the new flag everywhere (is_subtype(), is_proper_subtype(), is_equivalent(), is_same_type() can call each other).

cc @Michael0x2a

This was referenced Aug 20, 2022
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@ilevkivskyi
Copy link
Member Author

mypy_primer output is technically correct. We (intentionally?) use is_subtype_no_promote() everywhere for overload checks. And this PR passes subtype flags to nested subtype checks. So people need to write e.g. Union[Iterable[int], Iterable[float]] in the implementation signature.

I am not sure why do we require this? If it looks to strict, I think it is easy to go back to using just is_subtype(). @Michael0x2a what was the motivation to ignore promotions during overload implementation signature check?

@ilevkivskyi
Copy link
Member Author

Well, FWIW I switched to is_subtype() and all tests passed. So I guess it was not really an intentional decision. Let's see what it will do here.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

pandas (https://github.com/pandas-dev/pandas)
- pandas/core/apply.py:510: error: Key expression in dictionary comprehension has incompatible type "Hashable"; expected type "NDFrame"  [misc]

@ilevkivskyi
Copy link
Member Author

Yeah, mypy_primer looks better now.

@hauntsaninja
Copy link
Collaborator

Looks great!

@ilevkivskyi ilevkivskyi merged commit 2ba6451 into python:master Aug 21, 2022
@ilevkivskyi ilevkivskyi deleted the fix-overload-overlap branch August 21, 2022 09:26
ilevkivskyi added a commit that referenced this pull request Sep 29, 2022
The issue was exposed by merge of subtype visitors. Fix is actually trivial, but the diff is big because I need to add and pass the new flag everywhere (`is_subtype()`, `is_proper_subtype()`, `is_equivalent()`, `is_same_type()` can call each other).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants