Skip to content

Misleading error when using a dict of keyword args #14073

@canepan

Description

@canepan

Bug Report

When passing at least part of the function parameter as an ** expanded dictionary, if one or more of the parameters is missing, a misleading "incomaptible type" is shown, instead of "missing parameter".
See also stackoverflow for a way to get a better (but still not correct, since it lists all the parameters as missing) message

To Reproduce

def my_func(a: str = 'Hello', b: bool = False, c: int = 1):
    return a, b, c


input_kwargs = {'b': True}
result = my_func(**input_kwargs)

or see the gist

Actual Behavior

main.py:14: error: Argument 1 to "fib" has incompatible type "**Dict[str, int]"; expected "str"
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 0.812 (or 0.981 on mypy-play)
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
check_untyped_defs = True
show_error_codes = True
pretty = True
ignore_missing_imports = True
  • Python version used: 3.8 (or 3.10 on mypy-play)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions