Skip to content

Allow overloading to succeed if an arg is an instance of a class derived from Any. Fix #1363. #1365

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
Apr 13, 2016

Conversation

gvanrossum
Copy link
Member

This has some tests that simulate the reported problem, and the hack makes them pass; but the reported case still fails outside the test harness (probably because fixtures/dict.py doesn't overload __init__).

@gvanrossum gvanrossum changed the title WIP - do not merge - see #1363 Allow overloading to succeed if an arg is an instance of a class derived from Any Apr 12, 2016
@gvanrossum gvanrossum changed the title Allow overloading to succeed if an arg is an instance of a class derived from Any Allow overloading to succeed if an arg is an instance of a class derived from Any. Fix #1363. Apr 12, 2016
@gvanrossum gvanrossum added the bug mypy got something wrong label Apr 12, 2016
@gvanrossum gvanrossum self-assigned this Apr 12, 2016
@gvanrossum
Copy link
Member Author

@JukkaL please review. This is the cleaned-up version of what we discussed today.

@gvanrossum gvanrossum removed the bug mypy got something wrong label Apr 12, 2016
@gvanrossum gvanrossum removed their assignment Apr 12, 2016
@@ -1625,7 +1625,8 @@ def overload_arg_similarity(actual: Type, formal: Type) -> int:
"""
if (isinstance(actual, NoneTyp) or isinstance(actual, AnyType) or
isinstance(formal, AnyType) or isinstance(formal, TypeVarType) or
isinstance(formal, CallableType)):
isinstance(formal, CallableType) or
isinstance(actual, Instance) and actual.type.fallback_to_any):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add parentheses around the and expression for clarity.

@JukkaL
Copy link
Collaborator

JukkaL commented Apr 13, 2016

Looks good, other than the nits above.

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.

2 participants