Skip to content

Possible bug: "Too many arguments for" error depends on presence of annotations in calling method signature. #9072

@Jasha10

Description

@Jasha10

mypy checks the following without error:

# tmp.py
def xyz():
    ...
def caller(self, a, **kwargs):
    print(a)
    xyz(**kwargs)

However, I get an error when I add a type signature to the argument a in caller:

# tmp_with_signature.py
def xyz():
    ...
def caller(self, a: int, **kwargs):
    print(a)
    xyz(**kwargs)

Mypy gives the following error message:

$ mypy tmp_with_signature.py
tmp_with_signature.py:6: error: Too many arguments for "xyz"
Found 1 error in 1 file (checked 1 source file)

It is strange to me that the error is only reported when a has an annotation, which seems unrelated to the number keyword arguments being passed to xyz. If I change each instance of **kwargs to *args, the error goes away. Seems like a bug...

Mypy version: 0.790+dev.007b7af9f96df9d23744d93fdf54e83bcdc01630
CPython version: 3.8.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions