Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error passing ** keyword args to function with multiple optional arguments of different types #7553

Closed
pdebelak opened this issue Sep 23, 2019 · 1 comment

Comments

@pdebelak
Copy link

This is a bug report present in mypy 0.720 (currently lastest mypy).

I get an unexpected type error when trying to pass ** keyword args to a function with multiple optional arguments of different types.

Take this example code:

from typing import Optional


def a_func(arg1: Optional[str] = None, arg2: Optional[int] = None):
    pass


a_func(**{"arg2": 1})

I would expect this to report no type errors, but instead I get:

error: Argument 1 to "a_func" has incompatible type "**Dict[str, int]"; expected "Optional[str]"

Is there a way to get this to pass mypy checking? My real code involves passing a dynamic kwarg (like year, month, or week) along with a length to create several differentdateutil.relativedelta instances so rewriting it to not use ** would involve rewriting the real code to have a large number of conditionals.

@ilevkivskyi
Copy link
Member

This is a duplicate of #5382

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants