Skip to content

Commit c0f2103

Browse files
elazargJukkaL
authored andcommitted
Allow **kwargs after bare asterisk (#2099)
Fix #142.
1 parent 301847b commit c0f2103

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

mypy/checkexpr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ def check_argument_count(self, callee: CallableType, actual_types: List[Type],
670670
messages.duplicate_argument_value(callee, i, context)
671671
ok = False
672672
elif (kind == nodes.ARG_NAMED and formal_to_actual[i] and
673-
actual_kinds[formal_to_actual[i][0]] != nodes.ARG_NAMED):
673+
actual_kinds[formal_to_actual[i][0]] not in [nodes.ARG_NAMED, nodes.ARG_STAR2]):
674674
# Positional argument when expecting a keyword argument.
675675
if messages:
676676
messages.too_many_positional_arguments(callee, context)

test-data/unit/check-kwargs.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ f(A(), B()) # E: Too many positional arguments for "f"
122122
class A: pass
123123
class B: pass
124124

125+
[case testKwargsAfterBareArgs]
126+
from typing import Tuple, Any
127+
def f(a, *, b=None) -> None: pass
128+
a = None # type: Any
129+
b = None # type: Any
130+
f(a, **b)
131+
132+
[builtins fixtures/dict.pyi]
133+
125134
[case testKeywordArgAfterVarArgs]
126135
import typing
127136
def f(*a: 'A', b: 'B' = None,) -> None: pass

0 commit comments

Comments
 (0)