Skip to content

Commit 7838906

Browse files
Rename test case
1 parent 0152d30 commit 7838906

File tree

1 file changed

+31
-32
lines changed

1 file changed

+31
-32
lines changed

test-data/unit/check-kwargs.test

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,37 @@ f(**d)
347347
class A: pass
348348
[builtins fixtures/dict.pyi]
349349

350+
[case testPassingMappingLiteralsForKeywordVarArg]
351+
from typing import Mapping, Any, Union
352+
from typing_extensions import Literal
353+
def f(a=None, b=None, **kwargs) -> None: pass
354+
def g(a: int, b: int) -> None: pass # N: "g" defined here
355+
def h(a: int, b: int, **kwargs) -> None: pass
356+
357+
s: Mapping[Literal[3], int] = {3: 2}
358+
f(**s) # E: Keywords must be strings
359+
360+
t: Mapping[Literal['b'], int] = {'b':2}
361+
f(**t)
362+
h(**t)
363+
364+
u: Mapping[Literal['c'], int] = {'b':2} \
365+
# E: Dict entry 0 has incompatible type "Literal['b']": "int"; expected "Literal['c']": "int"
366+
f(**u)
367+
368+
v: Mapping[Literal['a','b'], int] = {'a':2, 'b':1}
369+
f(**v)
370+
371+
w: Mapping[Literal['d'], int] = {'c':2} \
372+
# E: Dict entry 0 has incompatible type "Literal['c']": "int"; expected "Literal['d']": "int"
373+
f(**w)
374+
375+
x: Mapping[Literal['c','d'], int] = {'c':1, 'd': 2}
376+
g(**x) # E: Unexpected keyword argument "c" for "g"
377+
h(**x) # E: Missing positional arguments "a", "b" in call to "h"
378+
379+
[builtins fixtures/dict.pyi]
380+
350381
[case testInvalidTypeForKeywordVarArg]
351382
from typing import Dict
352383
def f(**kwargs: 'A') -> None: pass
@@ -552,35 +583,3 @@ main:31: error: Argument after ** must be a mapping, not "C[str, float]"
552583
main:32: error: Argument after ** must be a mapping, not "D"
553584
main:33: error: Argument 1 to "foo" has incompatible type "**Dict[str, str]"; expected "float"
554585
[builtins fixtures/dict.pyi]
555-
556-
557-
[case testGivingArgumentAsPositionalAndKeywordArg3]
558-
from typing import Mapping, Any, Union
559-
from typing_extensions import Literal
560-
def f(a=None, b=None, **kwargs) -> None: pass
561-
def g(a: int, b: int) -> None: pass # N: "g" defined here
562-
def h(a: int, b: int, **kwargs) -> None: pass
563-
564-
s: Mapping[Literal[3], int] = {3: 2}
565-
f(**s) # E: Keywords must be strings
566-
567-
t: Mapping[Literal['b'], int] = {'b':2}
568-
f(**t)
569-
h(**t)
570-
571-
u: Mapping[Literal['c'], int] = {'b':2} \
572-
# E: Dict entry 0 has incompatible type "Literal['b']": "int"; expected "Literal['c']": "int"
573-
f(**u)
574-
575-
v: Mapping[Literal['a','b'], int] = {'a':2, 'b':1}
576-
f(**v)
577-
578-
w: Mapping[Literal['d'], int] = {'c':2} \
579-
# E: Dict entry 0 has incompatible type "Literal['c']": "int"; expected "Literal['d']": "int"
580-
f(**w)
581-
582-
x: Mapping[Literal['c','d'], int] = {'c':1, 'd': 2}
583-
g(**x) # E: Unexpected keyword argument "c" for "g"
584-
h(**x) # E: Missing positional arguments "a", "b" in call to "h"
585-
586-
[builtins fixtures/dict.pyi]

0 commit comments

Comments
 (0)