Skip to content

Commit cc4fcf3

Browse files
committed
added unpack test cases
1 parent 57d4dd2 commit cc4fcf3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test-data/unit/check-functions.test

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3566,3 +3566,29 @@ class Bar(Foo):
35663566

35673567
def foo(self, value: Union[int, str]) -> Union[int, str]:
35683568
return super().foo(value) # E: Call to abstract method "foo" of "Foo" with trivial body via super() is unsafe
3569+
3570+
[case testInvalidUnpack]
3571+
from foo import bar # type: ignore[import-not-found]
3572+
from typing import Any
3573+
3574+
def g(x: Any):
3575+
pass
3576+
3577+
def baz(x: int):
3578+
return bar(*x, **x) # E: Expected iterable as variadic argument # E: Argument after ** must be a mapping, not "int"
3579+
3580+
def f1(x: int):
3581+
return g(**x) # E: Argument after ** must be a mapping, not "int"
3582+
3583+
def f2(x: list[int]):
3584+
return g(*x)
3585+
3586+
def f3(x: Any):
3587+
return g(*x)
3588+
3589+
from typing import Optional
3590+
def f4(x: Optional[int]):
3591+
return g(*x) # E: Expected iterable as variadic argument
3592+
3593+
def f(x: int):
3594+
return g(*x) # E: Expected iterable as variadic argument

0 commit comments

Comments
 (0)