Skip to content

Do not crash in "too few arguments" error with anon argument #3313

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

Merged
merged 5 commits into from
May 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def too_few_arguments(self, callee: CallableType, context: Context,
msg = 'Missing positional argument'
else:
msg = 'Missing positional arguments'
if callee.name and diff:
if callee.name and diff and all(d is not None for d in diff):
msg += ' "{}" in call to {}'.format('", "'.join(diff), callee.name)
else:
msg = 'Too few arguments'
Expand Down
5 changes: 5 additions & 0 deletions test-data/unit/check-functions.test
Original file line number Diff line number Diff line change
Expand Up @@ -2039,3 +2039,8 @@ l: List[int] = make_list()

bad = make_list() # E: Need type annotation for variable
[builtins fixtures/list.pyi]

[case testAnonymousArgumentError]
def foo(__b: int, x: int, y: int) -> int: pass
foo(x=2, y=2) # E: Missing positional argument
foo(y=2) # E: Missing positional arguments