(🐞) Wrong error message on overloaded function with unexpected keyword parameter
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
No overload variant of "foo" matches argument type "int"
This error message is flat out incorrect as there is a variant that matches int but there is an unexpected parameter name.
from typing import overload
@overload
def foo(a: int) -> None: ...
@overload
def foo(a: str) -> None: ...
def foo(a: object) -> None: ...
def bar(a: int) -> None: ...
foo(b=1)
bar(b=1)
main.py:11: note: "bar" defined here
main.py:13: error: No overload variant of "foo" matches argument type "int" [call-overload]
main.py:13: note: Possible overload variants:
main.py:13: note: def foo(a: int) -> None
main.py:13: note: def foo(a: str) -> None
main.py:14: error: Unexpected keyword argument "b" for "bar" [call-arg]
Found 2 errors in 1 file (checked 1 source file)
Also
In that output, for what reason is there a random main.py:11: note: "bar" defined here? Should I raise that as a separate issue?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied main.py reproducer or the linked mypy playground and compare the diagnostics for overloaded foo with non-overloaded bar. Trace the overload error-reporting path and verify that the completed behavior distinguishes an unexpected keyword from an argument-type mismatch, while checking the unrelated bar definition note shown in the same output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100