Skip to content

False positive with splat and explicit kwarg #20441

@torfsen

Description

@torfsen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongpendingIssues that may be closed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions