Skip to content

Commit

Permalink
Allow **kwargs after bare asterisk (python#2099)
Browse files Browse the repository at this point in the history
  • Loading branch information
elazarg authored and JukkaL committed Sep 7, 2016
1 parent 301847b commit c0f2103
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ def check_argument_count(self, callee: CallableType, actual_types: List[Type],
messages.duplicate_argument_value(callee, i, context)
ok = False
elif (kind == nodes.ARG_NAMED and formal_to_actual[i] and
actual_kinds[formal_to_actual[i][0]] != nodes.ARG_NAMED):
actual_kinds[formal_to_actual[i][0]] not in [nodes.ARG_NAMED, nodes.ARG_STAR2]):
# Positional argument when expecting a keyword argument.
if messages:
messages.too_many_positional_arguments(callee, context)
Expand Down
9 changes: 9 additions & 0 deletions test-data/unit/check-kwargs.test
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ f(A(), B()) # E: Too many positional arguments for "f"
class A: pass
class B: pass

[case testKwargsAfterBareArgs]
from typing import Tuple, Any
def f(a, *, b=None) -> None: pass
a = None # type: Any
b = None # type: Any
f(a, **b)

[builtins fixtures/dict.pyi]

[case testKeywordArgAfterVarArgs]
import typing
def f(*a: 'A', b: 'B' = None,) -> None: pass
Expand Down

0 comments on commit c0f2103

Please sign in to comment.