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

Incorrect handling of kwargs when default values are present #5809

Closed
takeda opened this issue Oct 19, 2018 · 2 comments
Closed

Incorrect handling of kwargs when default values are present #5809

takeda opened this issue Oct 19, 2018 · 2 comments

Comments

@takeda
Copy link

takeda commented Oct 19, 2018

I have a following code:

#! /usr/bin/env python

from typing import Any

def function(a, b, c=False, **kwargs):
	# type: (str, int, bool, **Any) -> None

	print "Got the following:", repr(a), repr(b), repr(c), repr(kwargs)

def main():
	# type: () -> None

	function('a', 2, **{'optional1': 1})

if __name__ == '__main__':
	main()

When I run it it produces this result:

$ ./test.py
Got the following: 'a' 2 False {'optional1': 1}

It looks like mypy thinks that the kwargs were passed as argument c which is incorrect:

$ ../py37/bin/mypy --python-executable ../py27/bin/python test.py
test.py:13: error: Argument 3 to "function" has incompatible type "**Dict[str, int]"; expected "bool"

The mypy version is 0.641

@ilevkivskyi
Copy link
Member

For mypy this is just a dictionary, even if it is just a literal, so this is a duplicate of #5382.

@ilevkivskyi
Copy link
Member

I looks like I mentioned wrong issue when closing, this is not a duplicate of #5382 but of #1969

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