Skip to content

Multiple dict unpacking for function arguments gives type errorΒ #4708

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy