False-positive with multiple *args splats in a function call
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
mypy falsely(?) reports a type error when the *args syntax is used more than once in a function call.
To Reproduce
mypy --no-incremental --config /dev/null -c '
def foobar(a: int, b: str, c: int) -> None:
...
foo = (1,)
bar = ("b", 3)
foobar(*foo, *bar)
'
Expected Behavior
Success: no issues found in 1 source file
Actual Behavior
<string>:9: error: Argument 2 to "foobar" has incompatible type "*Tuple[str, int]"; expected "str"
<string>:9: error: Argument 2 to "foobar" has incompatible type "*Tuple[str, int]"; expected "int"
This error goes away if I:
- make
fooanintinstead ofTuple[int], and remove the splat whenfoobar()is called. - make
bartwo ints and makefoobar()take three int arguments. - make
fooaTuple[str, int]and makefoobar()takestr, int, str, intarguments. - make
barjust aTuple[str]and makefoobar()takeint, strarguments.
Your Environment
This occurs with the standard version of mypy in Debian Testing:
$ /usr/bin/mypy --version
mypy 0.812
...as well as with the latest git revision:
$ ~/.local/pipx/venvs/mypy/bin/mypy --version
mypy 0.820+dev.8642b351cff94c471333256f9cd6867807384f01
In both cases, I'm using the Debian-provided Python 3.9.2,
on up-to-date Debian Testing.
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 by running the supplied mypy command and confirming the two diagnostics for the call with multiple tuple splats. Trace the call argument checking and tuple-splat handling, then add coverage for this reproducer; done means the command reports no issues without regressing the listed variations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100