Skip to content

Call to overloaded function with Any argument results in too precise type #3914

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

Closed
JukkaL opened this issue Sep 4, 2017 · 2 comments
Closed

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Sep 4, 2017

The inferred type of f(a) below is int. It would be better to infer Any, since the correct type can't be predicted due to the Any argument type:

from typing import overload, Any

@overload
def f(x: int) -> int: ...
@overload
def f(x: object) -> object: ...
def f(x): pass

a: Any
reveal_type(f(a))  # int (but should be Any)

This blocks PR #3300 from being merged, since the PR will expose additional cases where a too precise type is inferred.

@ilevkivskyi
Copy link
Member

Isn't this just a duplicate of #3662?

@JukkaL
Copy link
Collaborator Author

JukkaL commented Sep 5, 2017

Oops, this a dupe (though the example is slightly different).

@JukkaL JukkaL closed this as completed Sep 5, 2017
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

No branches or pull requests

2 participants