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

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

Closed
Jasha10 opened this issue Jun 30, 2020 · 1 comment

Comments

@Jasha10
Copy link

Jasha10 commented Jun 30, 2020

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

@JelleZijlstra
Copy link
Member

This is because mypy by default only checks annotated functions. See https://mypy.readthedocs.io/en/stable/common_issues.html#no-errors-reported-for-obviously-wrong-code.

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