You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This spawned off #1553. The mapping of argument type from a call site to a function definition is complicated by the existence of *args, **kwds, optional args, and keyword-only args.
For example, Python 3.5+ support multiple *args in a call! (But not in a definition.) So this (valid) code gives two errors while there should be none:
deff(*a: int) ->int: returnsum(a)
f(*[1, 2, 3], *[4, 5], 6) # E: Too many arguments for "f"f(*(1, 2, 3), *(4, 5), 6) # E: Too many arguments for "f"
(It also doesn't give a SyntaxError with --python-version=3.4 as it should.)
The text was updated successfully, but these errors were encountered:
Here's another example of something that doesn't work:
deff(*a: int) ->None:
print(a)
f(1, 2, 3, 4) # okf(1, 2, *[3, 4]) # okf(*[1, 2], 3, 4) # E: Too many arguments for "f"
The reason in this case is that [1, 2] is treated as just List[int] and a *x argument where x is a sequence type, when the corresponding formal is also a * argument, is assumed to "fill up" the entire *args.
This spawned off #1553. The mapping of argument type from a call site to a function definition is complicated by the existence of
*args
,**kwds
, optional args, and keyword-only args.For example, Python 3.5+ support multiple
*args
in a call! (But not in a definition.) So this (valid) code gives two errors while there should be none:(It also doesn't give a SyntaxError with
--python-version=3.4
as it should.)The text was updated successfully, but these errors were encountered: