Skip to content

Give better error messages when calling overloaded function with invalid types #672

Closed

Description

@JukkaL

Currently when calling an overloaded function, the error message is something like No overload variant of "foo" matches argument types. Instead, we should try to give a message like Argument 1 to "foo" has incompatible type "int"; expected "str" or "bytes", which is more informative. This may not be always possible, but we should be able to do it at least most of the time.

Activity

  1. JukkaL commented on May 23, 2017

    @JukkaL
    CollaboratorAuthor

    Also, if we can't give a specific message, we could print out the full signature of the target overloaded function as a note after the message. This would make it easier to see why the call is rejected by mypy.

  2. ilevkivskyi commented on May 14, 2018

    @ilevkivskyi
    Member

    I think just listing argument types and the overloads in a note may be enough. Also protocol notes already contain relevant code for nice compact formatting of overloads.

  3. JukkaL commented on May 14, 2018

    @JukkaL
    CollaboratorAuthor

    The implementation of protocol notes lives in report_protocol_problems in mypy.messages. Overload messages are generated in no_variant_matches_arguments in the same module.

  4. MentalMegalodon commented on May 15, 2018

    @MentalMegalodon
    Contributor

    I'm working on it.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions