Skip to content

Commit 7675c99

Browse files
committed
added tests
1 parent 1ec21b5 commit 7675c99

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

test-data/unit/check-expressions.test

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,3 +2721,51 @@ g(x="hello", y=1) # E: No overload variant of "g" matches argument types "str",
27212721
# N: def g(x: int, y: int) -> int \
27222722
# N: def g(x: str, y: str) -> str
27232723
[builtins fixtures/list.pyi]
2724+
2725+
[case testOverloadMixedArgsWithNonFirstKeywordTypo]
2726+
from typing import overload, Union
2727+
2728+
@overload
2729+
def f(x: int, name: int, value: int) -> None: ...
2730+
2731+
@overload
2732+
def f(x: str, name: str, value: str) -> None: ...
2733+
2734+
def f(x: Union[int, str], name: Union[int, str], value: Union[int, str]) -> None: pass
2735+
2736+
f(1, name=2, valeu=3) # E: Unexpected keyword argument "valeu" for overloaded function "f"; did you mean "value"? \
2737+
# E: No overload variant of "f" matches argument types "int", "int", "int" \
2738+
# N: Possible overload variants: \
2739+
# N: def f(x: int, name: int, value: int) -> None \
2740+
# N: def f(x: str, name: str, value: str) -> None
2741+
[builtins fixtures/list.pyi]
2742+
2743+
[case testOverloadTwoMisspelledKeywordsDifferentTargets]
2744+
from typing import overload, Union
2745+
2746+
@overload
2747+
def f(name: int, value: int) -> None: ...
2748+
2749+
@overload
2750+
def f(name: str, value: str) -> None: ...
2751+
2752+
def f(name: Union[int, str], value: Union[int, str]) -> None: pass
2753+
2754+
f(nme=1, valeu=2) # E: Unexpected keyword argument "nme" for overloaded function "f"; did you mean "name"? \
2755+
# E: Unexpected keyword argument "valeu" for overloaded function "f"; did you mean "value"?
2756+
[builtins fixtures/list.pyi]
2757+
2758+
[case testOverloadMethodKeywordTypo]
2759+
from typing import overload, Union
2760+
2761+
class A:
2762+
@overload
2763+
def f(self, foobar: int) -> None: ...
2764+
2765+
@overload
2766+
def f(self, foobar: str) -> None: ...
2767+
2768+
def f(self, foobar: Union[int, str]) -> None: pass
2769+
2770+
A().f(fobar=1) # E: Unexpected keyword argument "fobar" for overloaded function "f" of "A"; did you mean "foobar"?
2771+
[builtins fixtures/list.pyi]

0 commit comments

Comments
 (0)