Skip to content

Type checker rejects call with both *args and a keyword arg #153

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

Closed
JukkaL opened this issue Feb 20, 2013 · 3 comments
Closed

Type checker rejects call with both *args and a keyword arg #153

JukkaL opened this issue Feb 20, 2013 · 3 comments
Labels
bug mypy got something wrong

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Feb 20, 2013

The following code is not accepted by the type checker, even though it's arguably valid:

def f(a, x=1): pass
f(*[1], x=2)   # Error: multiple values for keyword argument "x"

The type checker should probably not complain about multiple argument values if one of the values is from a *arg.

The limitation can be worked around by replacing keyword args with dict args (**args).

JukkaL added a commit that referenced this issue Feb 20, 2013
Keyword argument is not accepted since it is used together with *args.

See also issue #153.
@JukkaL JukkaL removed the front end label Jul 25, 2014
@JukkaL
Copy link
Collaborator Author

JukkaL commented Dec 18, 2014

Also, this should work but isn't accepted:

def f(a, x): pass
f(x=2, *[1])   # Error: multiple values for keyword argument "x"

@JukkaL
Copy link
Collaborator Author

JukkaL commented Feb 21, 2015

Actually, maybe the first example should not be valid, since we can't check that there are no multiple argument values due to not knowing the length of the *args list.

We can revisit this later if it turns out to be problematic.

@JukkaL
Copy link
Collaborator Author

JukkaL commented Feb 21, 2015

I committed a partial fix now that fixes the parser issue.

@JukkaL JukkaL closed this as completed Feb 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant