Skip to content

Commit 59c2a2c

Browse files
committed
update typeddict kwarg forwarding test
1 parent 043e01d commit 59c2a2c

9 files changed

Lines changed: 265 additions & 126 deletions

File tree

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
11
conformant = "Partial"
22
notes = """
33
Allows callable without kwargs to be assigned to callable with unpacked kwargs.
4+
Does not support the `closed` and `extra_items` TypedDict class arguments.
5+
Does not reject passing unpacked kwargs typed with a non-closed TypedDict to a callable that has no `**kwargs`.
6+
Does not reject passing unpacked kwargs typed with a TypedDict that has `extra_items` to a callable that has no `**kwargs`.
7+
Does not check the `extra_items` type of unpacked kwargs against the target callable's `**kwargs` annotation.
48
"""
59
output = """
6-
callables_kwargs.py:46: error: Missing named argument "v1" for "func1" [call-arg]
7-
callables_kwargs.py:46: error: Missing named argument "v3" for "func1" [call-arg]
8-
callables_kwargs.py:51: error: Unexpected keyword argument "v4" for "func1" [call-arg]
9-
callables_kwargs.py:52: error: Too many positional arguments for "func1" [misc]
10-
callables_kwargs.py:58: error: Argument 1 to "func1" has incompatible type "**dict[str, str]"; expected "int" [arg-type]
11-
callables_kwargs.py:61: error: Argument 1 to "func1" has incompatible type "**dict[str, object]"; expected "int" [arg-type]
12-
callables_kwargs.py:61: error: Argument 1 to "func1" has incompatible type "**dict[str, object]"; expected "str" [arg-type]
13-
callables_kwargs.py:63: error: "func1" gets multiple values for keyword argument "v1" [misc]
14-
callables_kwargs.py:64: error: "func2" gets multiple values for keyword argument "v3" [misc]
15-
callables_kwargs.py:64: error: Argument 1 to "func2" has incompatible type "int"; expected "str" [arg-type]
16-
callables_kwargs.py:65: error: "func2" gets multiple values for keyword argument "v1" [misc]
17-
callables_kwargs.py:101: error: Incompatible types in assignment (expression has type "def func1(**kwargs: **TD2) -> None", variable has type "TDProtocol3") [assignment]
18-
callables_kwargs.py:101: note: "TDProtocol3.__call__" has type "def __call__(self, *, v1: int, v2: int, v3: str) -> None"
19-
callables_kwargs.py:102: error: Incompatible types in assignment (expression has type "def func1(**kwargs: **TD2) -> None", variable has type "TDProtocol4") [assignment]
20-
callables_kwargs.py:102: note: "TDProtocol4.__call__" has type "def __call__(self, *, v1: int) -> None"
21-
callables_kwargs.py:103: error: Incompatible types in assignment (expression has type "def func1(**kwargs: **TD2) -> None", variable has type "TDProtocol5") [assignment]
22-
callables_kwargs.py:103: note: "TDProtocol5.__call__" has type "def __call__(self, v1: int, v3: str) -> None"
23-
callables_kwargs.py:111: error: Overlap between parameter names and ** TypedDict items: "v1" [misc]
24-
callables_kwargs.py:122: error: Unpack item in ** parameter must be a TypedDict [misc]
10+
callables_kwargs.py:47: error: Missing named argument "v1" for "func1" [call-arg]
11+
callables_kwargs.py:47: error: Missing named argument "v3" for "func1" [call-arg]
12+
callables_kwargs.py:52: error: Unexpected keyword argument "v4" for "func1" [call-arg]
13+
callables_kwargs.py:53: error: Too many positional arguments for "func1" [misc]
14+
callables_kwargs.py:59: error: Argument 1 to "func1" has incompatible type "**dict[str, str]"; expected "int" [arg-type]
15+
callables_kwargs.py:62: error: Argument 1 to "func1" has incompatible type "**dict[str, object]"; expected "int" [arg-type]
16+
callables_kwargs.py:62: error: Argument 1 to "func1" has incompatible type "**dict[str, object]"; expected "str" [arg-type]
17+
callables_kwargs.py:64: error: "func1" gets multiple values for keyword argument "v1" [misc]
18+
callables_kwargs.py:65: error: "func2" gets multiple values for keyword argument "v3" [misc]
19+
callables_kwargs.py:65: error: Argument 1 to "func2" has incompatible type "int"; expected "str" [arg-type]
20+
callables_kwargs.py:66: error: "func2" gets multiple values for keyword argument "v1" [misc]
21+
callables_kwargs.py:102: error: Incompatible types in assignment (expression has type "def func1(**kwargs: **TD2) -> None", variable has type "TDProtocol3") [assignment]
22+
callables_kwargs.py:102: note: "TDProtocol3.__call__" has type "def __call__(self, *, v1: int, v2: int, v3: str) -> None"
23+
callables_kwargs.py:103: error: Incompatible types in assignment (expression has type "def func1(**kwargs: **TD2) -> None", variable has type "TDProtocol4") [assignment]
24+
callables_kwargs.py:103: note: "TDProtocol4.__call__" has type "def __call__(self, *, v1: int) -> None"
25+
callables_kwargs.py:104: error: Incompatible types in assignment (expression has type "def func1(**kwargs: **TD2) -> None", variable has type "TDProtocol5") [assignment]
26+
callables_kwargs.py:104: note: "TDProtocol5.__call__" has type "def __call__(self, v1: int, v3: str) -> None"
27+
callables_kwargs.py:112: error: Overlap between parameter names and ** TypedDict items: "v1" [misc]
28+
callables_kwargs.py:123: error: Unpack item in ** parameter must be a TypedDict [misc]
29+
callables_kwargs.py:145: error: Unexpected keyword argument "closed" for "__init_subclass__" of "TypedDict" [call-arg]
30+
callables_kwargs.py:149: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]
2531
"""
2632
conformance_automated = "Fail"
2733
errors_diff = """
28-
Line 134: Expected 1 errors
34+
Line 135: Expected 1 errors
35+
Line 167: Expected 1 errors
36+
Line 185: Expected 1 errors
37+
Line 186: Expected 1 errors
38+
Line 145: Unexpected errors ['callables_kwargs.py:145: error: Unexpected keyword argument "closed" for "__init_subclass__" of "TypedDict" [call-arg]']
39+
Line 149: Unexpected errors ['callables_kwargs.py:149: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]']
2940
"""
Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
1-
conformance_automated = "Pass"
1+
conformant = "Partial"
2+
notes = """
3+
Does not reject passing unpacked kwargs typed with a non-closed TypedDict to a callable that has no `**kwargs`.
4+
Does not reject passing unpacked kwargs typed with a TypedDict that has `extra_items` to a callable that has no `**kwargs`.
5+
Does not check the `extra_items` type of unpacked kwargs against the target callable's `**kwargs` annotation.
6+
"""
7+
conformance_automated = "Fail"
28
errors_diff = """
9+
Line 167: Expected 1 errors
10+
Line 185: Expected 1 errors
11+
Line 186: Expected 1 errors
312
"""
413
output = """
5-
./callables_kwargs.py:46:4: In call to callables_kwargs.func1: Missing required argument 'v1' [incompatible_call]
6-
./callables_kwargs.py:51:4: In call to callables_kwargs.func1: Got an unexpected keyword argument 'v4' [incompatible_call]
7-
./callables_kwargs.py:52:4: In call to callables_kwargs.func1: Missing required argument 'v1' [incompatible_call]
8-
./callables_kwargs.py:58:4: Incompatible argument type for v1: expected int but got str [incompatible_argument]
9-
./callables_kwargs.py:61:4: In call to callables_kwargs.func1: Got an unexpected keyword argument 'v4' [incompatible_call]
10-
./callables_kwargs.py:63:4: Multiple values provided for argument 'v1' [incompatible_call]
11-
./callables_kwargs.py:64:4: In call to callables_kwargs.func2: Parameter 'v3' provided as both a positional and a keyword argument [incompatible_call]
12-
./callables_kwargs.py:65:4: Multiple values provided for argument 'v1' [incompatible_call]
13-
./callables_kwargs.py:101:0: Incompatible assignment: expected callables_kwargs.TDProtocol3, got function 'callables_kwargs.func1' [incompatible_assignment]
14-
./callables_kwargs.py:102:0: Incompatible assignment: expected callables_kwargs.TDProtocol4, got function 'callables_kwargs.func1' [incompatible_assignment]
15-
./callables_kwargs.py:103:0: Incompatible assignment: expected callables_kwargs.TDProtocol5, got function 'callables_kwargs.func1' [incompatible_assignment]
16-
./callables_kwargs.py:111:21: Parameter v1 overlaps with TypedDict key in **kwargs [invalid_annotation]
17-
./callables_kwargs.py:122:12: Expected TypedDict type inside Unpack[] for **kwargs [invalid_annotation]
18-
./callables_kwargs.py:134:0: Incompatible assignment: expected callables_kwargs.TDProtocol6, got function 'callables_kwargs.func7' [incompatible_assignment]
14+
./callables_kwargs.py:47:4: In call to callables_kwargs.func1: Missing required argument 'v1' [incompatible_call]
15+
./callables_kwargs.py:52:4: In call to callables_kwargs.func1: Got an unexpected keyword argument 'v4' [incompatible_call]
16+
./callables_kwargs.py:53:4: In call to callables_kwargs.func1: Missing required argument 'v1' [incompatible_call]
17+
./callables_kwargs.py:59:4: Incompatible argument type for v1: expected int but got str [incompatible_argument]
18+
./callables_kwargs.py:62:4: In call to callables_kwargs.func1: Got an unexpected keyword argument 'v4' [incompatible_call]
19+
./callables_kwargs.py:64:4: Multiple values provided for argument 'v1' [incompatible_call]
20+
./callables_kwargs.py:65:4: In call to callables_kwargs.func2: Parameter 'v3' provided as both a positional and a keyword argument [incompatible_call]
21+
./callables_kwargs.py:66:4: Multiple values provided for argument 'v1' [incompatible_call]
22+
./callables_kwargs.py:102:0: Incompatible assignment: expected callables_kwargs.TDProtocol3, got function 'callables_kwargs.func1' [incompatible_assignment]
23+
./callables_kwargs.py:103:0: Incompatible assignment: expected callables_kwargs.TDProtocol4, got function 'callables_kwargs.func1' [incompatible_assignment]
24+
./callables_kwargs.py:104:0: Incompatible assignment: expected callables_kwargs.TDProtocol5, got function 'callables_kwargs.func1' [incompatible_assignment]
25+
./callables_kwargs.py:112:21: Parameter v1 overlaps with TypedDict key in **kwargs [invalid_annotation]
26+
./callables_kwargs.py:123:12: Expected TypedDict type inside Unpack[] for **kwargs [invalid_annotation]
27+
./callables_kwargs.py:135:0: Incompatible assignment: expected callables_kwargs.TDProtocol6, got function 'callables_kwargs.func7' [incompatible_assignment]
1928
"""
Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
1-
conformant = "Pass"
2-
conformance_automated = "Pass"
1+
conformant = "Partial"
2+
notes = """
3+
Does not reject passing unpacked kwargs typed with a non-closed TypedDict to a callable that has no `**kwargs`.
4+
Does not reject passing unpacked kwargs typed with a TypedDict that has `extra_items` to a callable that has no `**kwargs`.
5+
Does not check the `extra_items` type of unpacked kwargs against the target callable's `**kwargs` annotation.
6+
"""
7+
conformance_automated = "Fail"
38
errors_diff = """
9+
Line 167: Expected 1 errors
10+
Line 185: Expected 1 errors
11+
Line 186: Expected 1 errors
412
"""
513
output = """
6-
ERROR callables_kwargs.py:46:10-12: Missing argument `v1` in function `func1` [missing-argument]
7-
ERROR callables_kwargs.py:46:10-12: Missing argument `v3` in function `func1` [missing-argument]
8-
ERROR callables_kwargs.py:51:32-34: Unexpected keyword argument `v4` in function `func1` [unexpected-keyword]
9-
ERROR callables_kwargs.py:52:11-12: Expected argument `v1` to be passed by name in function `func1` [unexpected-positional-argument]
10-
ERROR callables_kwargs.py:52:11-12: Expected 0 positional arguments, got 3 in function `func1` [bad-argument-count]
11-
ERROR callables_kwargs.py:52:14-16: Expected argument `v3` to be passed by name in function `func1` [unexpected-positional-argument]
12-
ERROR callables_kwargs.py:58:11-20: Unpacked keyword argument `str` is not assignable to parameter `v1` with type `int` in function `func1` [bad-argument-type]
13-
ERROR callables_kwargs.py:63:17-22: Multiple values for argument `v1` in function `func1` [bad-keyword-argument]
14-
ERROR callables_kwargs.py:64:11-12: Argument `Literal[1]` is not assignable to parameter `v3` with type `str` in function `func2` [bad-argument-type]
15-
ERROR callables_kwargs.py:64:14-19: Multiple values for argument `v3` in function `func2` [bad-keyword-argument]
16-
ERROR callables_kwargs.py:65:17-22: Multiple values for argument `v1` in function `func2` [bad-keyword-argument]
17-
ERROR callables_kwargs.py:101:19-24: `(**kwargs: Unpack[TD2]) -> None` is not assignable to `TDProtocol3` [bad-assignment]
18-
ERROR callables_kwargs.py:102:19-24: `(**kwargs: Unpack[TD2]) -> None` is not assignable to `TDProtocol4` [bad-assignment]
19-
ERROR callables_kwargs.py:103:19-24: `(**kwargs: Unpack[TD2]) -> None` is not assignable to `TDProtocol5` [bad-assignment]
20-
ERROR callables_kwargs.py:111:20-41: TypedDict key 'v1' in **kwargs overlaps with parameter 'v1' [bad-function-definition]
21-
ERROR callables_kwargs.py:122:21-30: `Unpack` in **kwargs annotation must be used only with a `TypedDict` [invalid-annotation]
22-
ERROR callables_kwargs.py:134:19-24: `(*, v1: int, v3: str, v2: str = '') -> None` is not assignable to `TDProtocol6` [bad-assignment]
14+
ERROR callables_kwargs.py:47:10-12: Missing argument `v1` in function `func1` [missing-argument]
15+
ERROR callables_kwargs.py:47:10-12: Missing argument `v3` in function `func1` [missing-argument]
16+
ERROR callables_kwargs.py:52:32-34: Unexpected keyword argument `v4` in function `func1` [unexpected-keyword]
17+
ERROR callables_kwargs.py:53:11-12: Expected argument `v1` to be passed by name in function `func1` [unexpected-positional-argument]
18+
ERROR callables_kwargs.py:53:11-12: Expected 0 positional arguments, got 3 in function `func1` [bad-argument-count]
19+
ERROR callables_kwargs.py:53:14-16: Expected argument `v3` to be passed by name in function `func1` [unexpected-positional-argument]
20+
ERROR callables_kwargs.py:59:11-20: Unpacked keyword argument `str` is not assignable to parameter `v1` with type `int` in function `func1` [bad-argument-type]
21+
ERROR callables_kwargs.py:64:17-22: Multiple values for argument `v1` in function `func1` [bad-keyword-argument]
22+
ERROR callables_kwargs.py:65:11-12: Argument `Literal[1]` is not assignable to parameter `v3` with type `str` in function `func2` [bad-argument-type]
23+
ERROR callables_kwargs.py:65:14-19: Multiple values for argument `v3` in function `func2` [bad-keyword-argument]
24+
ERROR callables_kwargs.py:66:17-22: Multiple values for argument `v1` in function `func2` [bad-keyword-argument]
25+
ERROR callables_kwargs.py:102:19-24: `(**kwargs: Unpack[TD2]) -> None` is not assignable to `TDProtocol3` [bad-assignment]
26+
ERROR callables_kwargs.py:103:19-24: `(**kwargs: Unpack[TD2]) -> None` is not assignable to `TDProtocol4` [bad-assignment]
27+
ERROR callables_kwargs.py:104:19-24: `(**kwargs: Unpack[TD2]) -> None` is not assignable to `TDProtocol5` [bad-assignment]
28+
ERROR callables_kwargs.py:112:20-41: TypedDict key 'v1' in **kwargs overlaps with parameter 'v1' [bad-function-definition]
29+
ERROR callables_kwargs.py:123:21-30: `Unpack` in **kwargs annotation must be used only with a `TypedDict` [invalid-annotation]
30+
ERROR callables_kwargs.py:135:19-24: `(*, v1: int, v3: str, v2: str = '') -> None` is not assignable to `TDProtocol6` [bad-assignment]
2331
"""
Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,44 @@
1-
conformant = "Pass"
1+
conformant = "Partial"
2+
notes = """
3+
Does not reject passing unpacked kwargs typed with a non-closed TypedDict to a callable that has no `**kwargs`.
4+
Does not reject passing unpacked kwargs typed with a TypedDict that has `extra_items` to a callable that has no `**kwargs`.
5+
"""
26
output = """
3-
callables_kwargs.py:28:5 - error: Could not access item in TypedDict
7+
callables_kwargs.py:29:5 - error: Could not access item in TypedDict
48
  "v2" is not a required key in "TD2", so access may result in runtime exception (reportTypedDictNotRequiredAccess)
5-
callables_kwargs.py:46:5 - error: Arguments missing for parameters "v1", "v3" (reportCallIssue)
6-
callables_kwargs.py:51:32 - error: No parameter named "v4" (reportCallIssue)
7-
callables_kwargs.py:52:11 - error: Expected 0 positional arguments (reportCallIssue)
8-
callables_kwargs.py:58:13 - error: Argument of type "str" cannot be assigned to parameter "v1" of type "int" in function "func1"
9+
callables_kwargs.py:47:5 - error: Arguments missing for parameters "v1", "v3" (reportCallIssue)
10+
callables_kwargs.py:52:32 - error: No parameter named "v4" (reportCallIssue)
11+
callables_kwargs.py:53:11 - error: Expected 0 positional arguments (reportCallIssue)
12+
callables_kwargs.py:59:13 - error: Argument of type "str" cannot be assigned to parameter "v1" of type "int" in function "func1"
913
  "str" is not assignable to "int" (reportArgumentType)
10-
callables_kwargs.py:63:19 - error: Unable to match unpacked TypedDict argument to parameters
14+
callables_kwargs.py:64:19 - error: Unable to match unpacked TypedDict argument to parameters
1115
  Parameter "v1" is already assigned (reportCallIssue)
12-
callables_kwargs.py:64:16 - error: Unable to match unpacked TypedDict argument to parameters
16+
callables_kwargs.py:65:16 - error: Unable to match unpacked TypedDict argument to parameters
1317
  Parameter "v3" is already assigned (reportCallIssue)
14-
callables_kwargs.py:65:19 - error: Unable to match unpacked TypedDict argument to parameters
18+
callables_kwargs.py:66:19 - error: Unable to match unpacked TypedDict argument to parameters
1519
  Parameter "v1" is already assigned (reportCallIssue)
16-
callables_kwargs.py:101:19 - error: Type "(**kwargs: **TD2) -> None" is not assignable to declared type "TDProtocol3"
20+
callables_kwargs.py:102:19 - error: Type "(**kwargs: **TD2) -> None" is not assignable to declared type "TDProtocol3"
1721
  Type "(**kwargs: **TD2) -> None" is not assignable to type "(*, v1: int, v2: int, v3: str) -> None"
1822
    Keyword parameter "v2" of type "int" is incompatible with type "str"
1923
      "int" is not assignable to "str" (reportAssignmentType)
20-
callables_kwargs.py:102:19 - error: Type "(**kwargs: **TD2) -> None" is not assignable to declared type "TDProtocol4"
24+
callables_kwargs.py:103:19 - error: Type "(**kwargs: **TD2) -> None" is not assignable to declared type "TDProtocol4"
2125
  Type "(**kwargs: **TD2) -> None" is not assignable to type "(*, v1: int) -> None"
2226
    Extra parameter "v3" (reportAssignmentType)
23-
callables_kwargs.py:103:19 - error: Type "(**kwargs: **TD2) -> None" is not assignable to declared type "TDProtocol5"
27+
callables_kwargs.py:104:19 - error: Type "(**kwargs: **TD2) -> None" is not assignable to declared type "TDProtocol5"
2428
  Type "(**kwargs: **TD2) -> None" is not assignable to type "(v1: int, v3: str) -> None"
2529
    Function accepts too many positional parameters; expected 0 but received 2
2630
      Extra parameter "v1"
2731
      Extra parameter "v3" (reportAssignmentType)
28-
callables_kwargs.py:111:30 - error: Typed dictionary overlaps with keyword parameter: v1 (reportGeneralTypeIssues)
29-
callables_kwargs.py:122:21 - error: Expected TypedDict type argument for Unpack (reportGeneralTypeIssues)
30-
callables_kwargs.py:134:19 - error: Type "(*, v1: int, v3: str, v2: str = "") -> None" is not assignable to declared type "TDProtocol6"
32+
callables_kwargs.py:112:30 - error: Typed dictionary overlaps with keyword parameter: v1 (reportGeneralTypeIssues)
33+
callables_kwargs.py:123:21 - error: Expected TypedDict type argument for Unpack (reportGeneralTypeIssues)
34+
callables_kwargs.py:135:19 - error: Type "(*, v1: int, v3: str, v2: str = "") -> None" is not assignable to declared type "TDProtocol6"
3135
  Type "(*, v1: int, v3: str, v2: str = "") -> None" is not assignable to type "(**kwargs: **TD2) -> None"
3236
    Parameter "**kwargs" has no corresponding parameter (reportAssignmentType)
37+
callables_kwargs.py:186:29 - error: Argument of type "int" cannot be assigned to parameter "kwargs" of type "str" in function "takes_name_str_kwargs"
38+
  "int" is not assignable to "str" (reportArgumentType)
3339
"""
34-
conformance_automated = "Pass"
40+
conformance_automated = "Fail"
3541
errors_diff = """
42+
Line 167: Expected 1 errors
43+
Line 185: Expected 1 errors
3644
"""

0 commit comments

Comments
 (0)