Skip to content

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

Closed

Description

@JukkaL

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).

Activity

  1. JukkaL commented on Dec 18, 2014

    @JukkaL
    CollaboratorAuthor

    Also, this should work but isn't accepted:

    def f(a, x): pass
    f(x=2, *[1])   # Error: multiple values for keyword argument "x"
  2. JukkaL commented on Feb 21, 2015

    @JukkaL
    CollaboratorAuthor

    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.

  3. JukkaL commented on Feb 21, 2015

    @JukkaL
    CollaboratorAuthor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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