diff --git a/mypy/messages.py b/mypy/messages.py index 6d52765115d2..f2df57412600 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -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' diff --git a/test-data/unit/check-functions.test b/test-data/unit/check-functions.test index f730de818242..c978c0e83353 100644 --- a/test-data/unit/check-functions.test +++ b/test-data/unit/check-functions.test @@ -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