Skip to content
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

Confusing error message when calling a function with incorrect *args #4771

Open
msullivan opened this issue Mar 20, 2018 · 0 comments
Open

Comments

@msullivan
Copy link
Collaborator

When typechecking this:

def foo(x: int, y: str) -> None: pass
t = ('hi', 12)
foo(*t)

mypy reports

bad_starargs.py:3: error: Argument 1 to "foo" has incompatible type "*Tuple[str, int]"; expected "int"
bad_starargs.py:3: error: Argument 1 to "foo" has incompatible type "*Tuple[str, int]"; expected "str"

This is not great, since Tuple[str, int] isn't being compared to something, and while it appears in argument position 1, the type mismatches don't necessarily.

A better error message might be something like:

bad_starargs.py:3: error: Argument 1 to "foo" has incompatible type "str"; expected "int"
bad_starargs.py:3: note: while unpacking "*Tuple[str, int]"
bad_starargs.py:3: error: Argument 2 to "foo" has incompatible type "int"; expected "str"
bad_starargs.py:3: note: while unpacking "*Tuple[str, int]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants