Skip to content

Multiple dict unpacking for function arguments gives type error #4708

Closed
@bmerrison

Description

@bmerrison

When I run the following code through MyPy:

def fn(a: int, b: int, c: int) -> None:
    print((a, b, c))

fn(**{'a': 10}, **{'b': 20, 'c': 30})

I receive the following:

$ python -m mypy mypy_problem.py
mypy_problem.py:8: error: Too many arguments for "fn"

I expect this to not give an error because as far as I know it's valid python code - it works at least! A workaround is to wrap the whole thing in another dictionary, i.e.:

fn(**{**{'a': 10}, **{'b': 20, 'c': 30}})

But this is messy and possibly introduces an additional overhead.

$ conda list | grep 'python\|mypy\|typed-ast'
mypy                      0.570                     <pip>
python                    3.5.2                         0    conda-forge
typed-ast                 1.1.0                     <pip>

I'm using Windows 7 64-bit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions