Skip to content

Commit 09e7b12

Browse files
sixoletgvanrossum
authored andcommitted
Do not crash in "too few arguments" error with anon argument (#3313)
Fix #3312
1 parent dfb94c1 commit 09e7b12

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

mypy/messages.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def too_few_arguments(self, callee: CallableType, context: Context,
575575
msg = 'Missing positional argument'
576576
else:
577577
msg = 'Missing positional arguments'
578-
if callee.name and diff:
578+
if callee.name and diff and all(d is not None for d in diff):
579579
msg += ' "{}" in call to {}'.format('", "'.join(diff), callee.name)
580580
else:
581581
msg = 'Too few arguments'

test-data/unit/check-functions.test

+5
Original file line numberDiff line numberDiff line change
@@ -2039,3 +2039,8 @@ l: List[int] = make_list()
20392039

20402040
bad = make_list() # E: Need type annotation for variable
20412041
[builtins fixtures/list.pyi]
2042+
2043+
[case testAnonymousArgumentError]
2044+
def foo(__b: int, x: int, y: int) -> int: pass
2045+
foo(x=2, y=2) # E: Missing positional argument
2046+
foo(y=2) # E: Missing positional arguments

0 commit comments

Comments
 (0)