Skip to content

Commit 06753e7

Browse files
committed
Weak mode varargs
1 parent a0283b4 commit 06753e7

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

mypy/checkexpr.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,9 @@ def check_argument_count(self, callee: CallableType, actual_types: List[Type],
482482
elif kind in [nodes.ARG_POS, nodes.ARG_OPT,
483483
nodes.ARG_NAMED] and is_duplicate_mapping(
484484
formal_to_actual[i], actual_kinds):
485-
self.msg.duplicate_argument_value(callee, i, context)
485+
if (self.chk.typing_mode_full() or
486+
isinstance(actual_type, TupleType)):
487+
self.msg.duplicate_argument_value(callee, i, context)
486488
elif (kind == nodes.ARG_NAMED and formal_to_actual[i] and
487489
actual_kinds[formal_to_actual[i][0]] != nodes.ARG_NAMED):
488490
# Positional argument when expecting a keyword argument.

mypy/test/data/check-weak-typing.test

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,18 @@ x = [1]
191191
# XXX: not clear what the right result here is
192192
x[0]() # E: "int" not callable
193193
[builtins fixtures/list.py]
194+
195+
[case testWeakArgsKws]
196+
# mypy: weak=global
197+
198+
def f(x, y):
199+
return x+y
200+
201+
args = [1]
202+
f(*args, y=2)
203+
args = (1, 2)
204+
f(*args, y=2) # E: "f" gets multiple values for keyword argument "y"
205+
args = (1,)
206+
f(*args, y=2)
207+
[builtins fixtures/dict.py]
208+
[out]

0 commit comments

Comments
 (0)