python / python/mypy

False positive with splat and explicit kwarg

Open
#20,441 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-calls
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Bug Report

Mypy reports multiple values for a kwarg if args are given via splat and the kwarg is explicitly set.

To Reproduce

def foo(x: int, y: int, z: str) -> None:
    print(x, y, z)

args = [1, 2]
foo(*args, z="...")

Expected Behavior

Mypy should not report any problems.

Actual Behavior

mypysandbox.py:5: error: "foo" gets multiple values for keyword argument "z"  [misc]
mypysandbox.py:5: error: Argument 1 to "foo" has incompatible type "*list[int]"; expected "str"  [arg-type]
Found 2 errors in 1 file (checked 1 source file)

Your Environment

$ mypy --version
mypy 1.19.1 (compiled: yes)
$ python --version
Python 3.12.12

Mypy config from pyproject.toml:

[tool.mypy]
strict = true
allow_redefinition =  true

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal Python reproducer in the issue and compare mypy's handling of a splatted list followed by an explicit keyword argument. Use the strict configuration from pyproject.toml when checking the behavior; done means the example produces no diagnostics, including no duplicate-keyword or incompatible-type errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.