Skip to content

Make overload impl checks correctly handle TypeVars and untyped impls #5236

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

Merged
merged 2 commits into from
Jun 25, 2018

Conversation

Michael0x2a
Copy link
Collaborator

This pull request fixes #4619 as well as an unrelated bug where if the overload implementation was untyped, we only check to see if there are unsafe overlaps between the first overload alternative and the rest.

This pull request fixes python#4619 as
well as an unrelated bug where if the overload implementation was untyped,
we only check to see if there are unsafe overlaps between the *first*
overload alternative and the rest.
@Michael0x2a Michael0x2a force-pushed the fix-overloads-impl-checks branch from 69b06a5 to 2d604fa Compare June 21, 2018 20:13
@Michael0x2a Michael0x2a requested a review from ilevkivskyi June 21, 2018 20:50
@ilevkivskyi ilevkivskyi self-assigned this Jun 21, 2018
Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good! I have only one comment.

mypy/checker.py Outdated
is_compat=is_subtype,
ignore_return=True):
ignore_return=True,
unify_generics=False):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function has already too many arguments. Is there a way to avoid unify_generics? Like if you already unified above, the unification in is_callable_compatible will be a no-op?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, that's weird. I could have sworn we needed this parameter, but I tried removing it and everything still worked. Maybe it was a holdover from one of my previous attempts at tackling the bug?

Anyways, I updated the PR to remove this param. Regarding the number of arguments: I'm planning on refactoring and splitting up is_callable_compatible in the upcoming PR for improving error messages -- that should help us cut down on the number of params/ad-hoc special casing.

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks! I will merge after some more testing.

@ilevkivskyi ilevkivskyi merged commit c5de2fd into python:master Jun 25, 2018
@Michael0x2a Michael0x2a deleted the fix-overloads-impl-checks branch June 26, 2018 06:42
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.

Errors when using overloaded functions and type variables
2 participants