Skip to content

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

Closed

Description

@JukkaL

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.

Activity

  1. ilevkivskyi commented on Sep 4, 2017

    @ilevkivskyi
    Member

    Isn't this just a duplicate of #3662?

  2. JukkaL commented on Sep 5, 2017

    @JukkaL
    CollaboratorAuthor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions