Skip to content

Commit 846feb7

Browse files
committed
address reviewer comments, revise spec and add a bunch of test cases
1 parent 2678723 commit 846feb7

9 files changed

Lines changed: 261 additions & 152 deletions

File tree

‎conformance/results/mypy/callables_kwargs.toml‎

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,51 @@ conformant = "Partial"
22
notes = """
33
Allows callable without kwargs to be assigned to callable with unpacked kwargs.
44
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`.
65
Does not reject passing unpacked kwargs typed with a TypedDict that has `extra_items` to a callable that has no `**kwargs`.
76
Does not check the `extra_items` type of unpacked kwargs against the target callable's `**kwargs` annotation.
87
"""
98
output = """
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]
9+
callables_kwargs.py:23: error: Unexpected keyword argument "closed" for "__init_subclass__" of "TypedDict" [call-arg]
10+
callables_kwargs.py:27: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]
11+
callables_kwargs.py:55: error: Missing named argument "v1" for "func1" [call-arg]
12+
callables_kwargs.py:55: error: Missing named argument "v3" for "func1" [call-arg]
13+
callables_kwargs.py:60: error: Unexpected keyword argument "v4" for "func1" [call-arg]
14+
callables_kwargs.py:61: error: Too many positional arguments for "func1" [misc]
15+
callables_kwargs.py:67: error: Argument 1 to "func1" has incompatible type "**dict[str, str]"; expected "int" [arg-type]
16+
callables_kwargs.py:70: error: Argument 1 to "func1" has incompatible type "**dict[str, object]"; expected "int" [arg-type]
17+
callables_kwargs.py:70: error: Argument 1 to "func1" has incompatible type "**dict[str, object]"; expected "str" [arg-type]
18+
callables_kwargs.py:72: error: "func1" gets multiple values for keyword argument "v1" [misc]
19+
callables_kwargs.py:73: error: "func2" gets multiple values for keyword argument "v3" [misc]
20+
callables_kwargs.py:73: error: Argument 1 to "func2" has incompatible type "int"; expected "str" [arg-type]
21+
callables_kwargs.py:74: error: "func2" gets multiple values for keyword argument "v1" [misc]
22+
callables_kwargs.py:121: error: Incompatible types in assignment (expression has type "def func1(**kwargs: **TD2) -> None", variable has type "TDProtocol3") [assignment]
23+
callables_kwargs.py:121: note: "TDProtocol3.__call__" has type "def __call__(self, *, v1: int, v2: int, v3: str) -> None"
24+
callables_kwargs.py:122: error: Incompatible types in assignment (expression has type "def func1(**kwargs: **TD2) -> None", variable has type "TDProtocol4") [assignment]
25+
callables_kwargs.py:122: note: "TDProtocol4.__call__" has type "def __call__(self, *, v1: int) -> None"
26+
callables_kwargs.py:123: error: Incompatible types in assignment (expression has type "def func1(**kwargs: **TD2) -> None", variable has type "TDProtocol5") [assignment]
27+
callables_kwargs.py:123: note: "TDProtocol5.__call__" has type "def __call__(self, v1: int, v3: str) -> None"
28+
callables_kwargs.py:131: error: Overlap between parameter names and ** TypedDict items: "v1" [misc]
29+
callables_kwargs.py:142: error: Unpack item in ** parameter must be a TypedDict [misc]
30+
callables_kwargs.py:166: error: Unexpected keyword argument "closed" for "__init_subclass__" of "TypedDict" [call-arg]
31+
callables_kwargs.py:170: error: Unexpected keyword argument "closed" for "__init_subclass__" of "TypedDict" [call-arg]
32+
callables_kwargs.py:174: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]
33+
callables_kwargs.py:178: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]
3134
"""
3235
conformance_automated = "Fail"
3336
errors_diff = """
34-
Line 135: Expected 1 errors
35-
Line 184: Expected 1 errors
36-
Line 185: Expected 1 errors
37-
Line 145: Unexpected errors ['callables_kwargs.py:145: error: Unexpected keyword argument "closed" for "__init_subclass__" of "TypedDict" [call-arg]']
38-
Line 149: Unexpected errors ['callables_kwargs.py:149: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]']
37+
Line 154: Expected 1 errors
38+
Line 206: Expected 1 errors
39+
Line 209: Expected 1 errors
40+
Line 215: Expected 1 errors
41+
Line 218: Expected 1 errors
42+
Line 231: Expected 1 errors
43+
Line 232: Expected 1 errors
44+
Line 234: Expected 1 errors
45+
Line 235: Expected 1 errors
46+
Line 23: Unexpected errors ['callables_kwargs.py:23: error: Unexpected keyword argument "closed" for "__init_subclass__" of "TypedDict" [call-arg]']
47+
Line 27: Unexpected errors ['callables_kwargs.py:27: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]']
48+
Line 166: Unexpected errors ['callables_kwargs.py:166: error: Unexpected keyword argument "closed" for "__init_subclass__" of "TypedDict" [call-arg]']
49+
Line 170: Unexpected errors ['callables_kwargs.py:170: error: Unexpected keyword argument "closed" for "__init_subclass__" of "TypedDict" [call-arg]']
50+
Line 174: Unexpected errors ['callables_kwargs.py:174: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]']
51+
Line 178: Unexpected errors ['callables_kwargs.py:178: error: Unexpected keyword argument "extra_items" for "__init_subclass__" of "TypedDict" [call-arg]']
3952
"""
Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
11
conformant = "Partial"
22
notes = """
3-
Does not reject passing unpacked kwargs typed with a non-closed TypedDict to a callable that has no `**kwargs`.
43
Does not reject passing unpacked kwargs typed with a TypedDict that has `extra_items` to a callable that has no `**kwargs`.
54
Does not check the `extra_items` type of unpacked kwargs against the target callable's `**kwargs` annotation.
65
"""
76
conformance_automated = "Fail"
87
errors_diff = """
9-
Line 184: Expected 1 errors
10-
Line 185: Expected 1 errors
8+
Line 206: Expected 1 errors
9+
Line 209: Expected 1 errors
10+
Line 215: Expected 1 errors
11+
Line 218: Expected 1 errors
12+
Line 231: Expected 1 errors
13+
Line 232: Expected 1 errors
14+
Line 234: Expected 1 errors
15+
Line 235: Expected 1 errors
16+
Line 155: Unexpected errors ["./callables_kwargs.py:155:0: Incompatible assignment: expected callables_kwargs.TDProtocol7, got function 'callables_kwargs.func7' [incompatible_assignment]"]
17+
Line 156: Unexpected errors ["./callables_kwargs.py:156:0: Incompatible assignment: expected callables_kwargs.TDProtocol8, got function 'callables_kwargs.func7' [incompatible_assignment]"]
1118
"""
1219
output = """
13-
./callables_kwargs.py:47:4: In call to callables_kwargs.func1: Missing required argument 'v1' [incompatible_call]
14-
./callables_kwargs.py:52:4: In call to callables_kwargs.func1: Got an unexpected keyword argument 'v4' [incompatible_call]
15-
./callables_kwargs.py:53:4: In call to callables_kwargs.func1: Missing required argument 'v1' [incompatible_call]
16-
./callables_kwargs.py:59:4: Incompatible argument type for v1: expected int but got str [incompatible_argument]
17-
./callables_kwargs.py:62:4: In call to callables_kwargs.func1: Got an unexpected keyword argument 'v4' [incompatible_call]
18-
./callables_kwargs.py:64:4: Multiple values provided for argument 'v1' [incompatible_call]
19-
./callables_kwargs.py:65:4: In call to callables_kwargs.func2: Parameter 'v3' provided as both a positional and a keyword argument [incompatible_call]
20-
./callables_kwargs.py:66:4: Multiple values provided for argument 'v1' [incompatible_call]
21-
./callables_kwargs.py:102:0: Incompatible assignment: expected callables_kwargs.TDProtocol3, got function 'callables_kwargs.func1' [incompatible_assignment]
22-
./callables_kwargs.py:103:0: Incompatible assignment: expected callables_kwargs.TDProtocol4, got function 'callables_kwargs.func1' [incompatible_assignment]
23-
./callables_kwargs.py:104:0: Incompatible assignment: expected callables_kwargs.TDProtocol5, got function 'callables_kwargs.func1' [incompatible_assignment]
24-
./callables_kwargs.py:112:21: Parameter v1 overlaps with TypedDict key in **kwargs [invalid_annotation]
25-
./callables_kwargs.py:123:12: Expected TypedDict type inside Unpack[] for **kwargs [invalid_annotation]
26-
./callables_kwargs.py:135:0: Incompatible assignment: expected callables_kwargs.TDProtocol6, got function 'callables_kwargs.func7' [incompatible_assignment]
20+
./callables_kwargs.py:55:4: In call to callables_kwargs.func1: Missing required argument 'v1' [incompatible_call]
21+
./callables_kwargs.py:60:4: In call to callables_kwargs.func1: Got an unexpected keyword argument 'v4' [incompatible_call]
22+
./callables_kwargs.py:61:4: In call to callables_kwargs.func1: Missing required argument 'v1' [incompatible_call]
23+
./callables_kwargs.py:67:4: Incompatible argument type for v1: expected int but got str [incompatible_argument]
24+
./callables_kwargs.py:70:4: In call to callables_kwargs.func1: Got an unexpected keyword argument 'v4' [incompatible_call]
25+
./callables_kwargs.py:72:4: Multiple values provided for argument 'v1' [incompatible_call]
26+
./callables_kwargs.py:73:4: In call to callables_kwargs.func2: Parameter 'v3' provided as both a positional and a keyword argument [incompatible_call]
27+
./callables_kwargs.py:74:4: Multiple values provided for argument 'v1' [incompatible_call]
28+
./callables_kwargs.py:121:0: Incompatible assignment: expected callables_kwargs.TDProtocol3, got function 'callables_kwargs.func1' [incompatible_assignment]
29+
./callables_kwargs.py:122:0: Incompatible assignment: expected callables_kwargs.TDProtocol4, got function 'callables_kwargs.func1' [incompatible_assignment]
30+
./callables_kwargs.py:123:0: Incompatible assignment: expected callables_kwargs.TDProtocol5, got function 'callables_kwargs.func1' [incompatible_assignment]
31+
./callables_kwargs.py:131:21: Parameter v1 overlaps with TypedDict key in **kwargs [invalid_annotation]
32+
./callables_kwargs.py:142:12: Expected TypedDict type inside Unpack[] for **kwargs [invalid_annotation]
33+
./callables_kwargs.py:154:0: Incompatible assignment: expected callables_kwargs.TDProtocol6, got function 'callables_kwargs.func7' [incompatible_assignment]
34+
./callables_kwargs.py:155:0: Incompatible assignment: expected callables_kwargs.TDProtocol7, got function 'callables_kwargs.func7' [incompatible_assignment]
35+
./callables_kwargs.py:156:0: Incompatible assignment: expected callables_kwargs.TDProtocol8, got function 'callables_kwargs.func7' [incompatible_assignment]
2736
"""
Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
11
conformant = "Partial"
22
notes = """
3-
Does not reject passing unpacked kwargs typed with a non-closed TypedDict to a callable that has no `**kwargs`.
43
Does not reject passing unpacked kwargs typed with a TypedDict that has `extra_items` to a callable that has no `**kwargs`.
54
Does not check the `extra_items` type of unpacked kwargs against the target callable's `**kwargs` annotation.
65
"""
76
conformance_automated = "Fail"
87
errors_diff = """
9-
Line 184: Expected 1 errors
10-
Line 185: Expected 1 errors
8+
Line 206: Expected 1 errors
9+
Line 209: Expected 1 errors
10+
Line 215: Expected 1 errors
11+
Line 218: Expected 1 errors
12+
Line 231: Expected 1 errors
13+
Line 232: Expected 1 errors
14+
Line 234: Expected 1 errors
15+
Line 235: Expected 1 errors
16+
Line 156: Unexpected errors ["`(*, v1: int, v3: str, v2: str = '') -> None` is not assignable to `TDProtocol8` [bad-assignment]"]
1117
"""
1218
output = """
13-
ERROR callables_kwargs.py:47:10-12: Missing argument `v1` in function `func1` [missing-argument]
14-
ERROR callables_kwargs.py:47:10-12: Missing argument `v3` in function `func1` [missing-argument]
15-
ERROR callables_kwargs.py:52:32-34: Unexpected keyword argument `v4` in function `func1` [unexpected-keyword]
16-
ERROR callables_kwargs.py:53:11-12: Expected argument `v1` to be passed by name in function `func1` [unexpected-positional-argument]
17-
ERROR callables_kwargs.py:53:11-12: Expected 0 positional arguments, got 3 in function `func1` [bad-argument-count]
18-
ERROR callables_kwargs.py:53:14-16: Expected argument `v3` to be passed by name in function `func1` [unexpected-positional-argument]
19-
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]
20-
ERROR callables_kwargs.py:64:17-22: Multiple values for argument `v1` in function `func1` [bad-keyword-argument]
21-
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]
22-
ERROR callables_kwargs.py:65:14-19: Multiple values for argument `v3` in function `func2` [bad-keyword-argument]
23-
ERROR callables_kwargs.py:66:17-22: Multiple values for argument `v1` in function `func2` [bad-keyword-argument]
24-
ERROR callables_kwargs.py:102:19-24: `(**kwargs: Unpack[TD2]) -> None` is not assignable to `TDProtocol3` [bad-assignment]
25-
ERROR callables_kwargs.py:103:19-24: `(**kwargs: Unpack[TD2]) -> None` is not assignable to `TDProtocol4` [bad-assignment]
26-
ERROR callables_kwargs.py:104:19-24: `(**kwargs: Unpack[TD2]) -> None` is not assignable to `TDProtocol5` [bad-assignment]
27-
ERROR callables_kwargs.py:112:20-41: TypedDict key 'v1' in **kwargs overlaps with parameter 'v1' [bad-function-definition]
28-
ERROR callables_kwargs.py:123:21-30: `Unpack` in **kwargs annotation must be used only with a `TypedDict` [invalid-annotation]
29-
ERROR callables_kwargs.py:135:19-24: `(*, v1: int, v3: str, v2: str = '') -> None` is not assignable to `TDProtocol6` [bad-assignment]
19+
ERROR callables_kwargs.py:55:10-12: Missing argument `v1` in function `func1` [missing-argument]
20+
ERROR callables_kwargs.py:55:10-12: Missing argument `v3` in function `func1` [missing-argument]
21+
ERROR callables_kwargs.py:60:32-34: Unexpected keyword argument `v4` in function `func1` [unexpected-keyword]
22+
ERROR callables_kwargs.py:61:11-12: Expected argument `v1` to be passed by name in function `func1` [unexpected-positional-argument]
23+
ERROR callables_kwargs.py:61:11-12: Expected 0 positional arguments, got 3 in function `func1` [bad-argument-count]
24+
ERROR callables_kwargs.py:61:14-16: Expected argument `v3` to be passed by name in function `func1` [unexpected-positional-argument]
25+
ERROR callables_kwargs.py:67:11-20: Unpacked keyword argument `str` is not assignable to parameter `v1` with type `int` in function `func1` [bad-argument-type]
26+
ERROR callables_kwargs.py:72:17-22: Multiple values for argument `v1` in function `func1` [bad-keyword-argument]
27+
ERROR callables_kwargs.py:73:11-12: Argument `Literal[1]` is not assignable to parameter `v3` with type `str` in function `func2` [bad-argument-type]
28+
ERROR callables_kwargs.py:73:14-19: Multiple values for argument `v3` in function `func2` [bad-keyword-argument]
29+
ERROR callables_kwargs.py:74:17-22: Multiple values for argument `v1` in function `func2` [bad-keyword-argument]
30+
ERROR callables_kwargs.py:121:19-24: `(**kwargs: Unpack[TD2]) -> None` is not assignable to `TDProtocol3` [bad-assignment]
31+
ERROR callables_kwargs.py:122:19-24: `(**kwargs: Unpack[TD2]) -> None` is not assignable to `TDProtocol4` [bad-assignment]
32+
ERROR callables_kwargs.py:123:19-24: `(**kwargs: Unpack[TD2]) -> None` is not assignable to `TDProtocol5` [bad-assignment]
33+
ERROR callables_kwargs.py:131:20-41: TypedDict key 'v1' in **kwargs overlaps with parameter 'v1' [bad-function-definition]
34+
ERROR callables_kwargs.py:142:21-30: `Unpack` in **kwargs annotation must be used only with a `TypedDict` [invalid-annotation]
35+
ERROR callables_kwargs.py:154:19-24: `(*, v1: int, v3: str, v2: str = '') -> None` is not assignable to `TDProtocol6` [bad-assignment]
36+
ERROR callables_kwargs.py:156:19-24: `(*, v1: int, v3: str, v2: str = '') -> None` is not assignable to `TDProtocol8` [bad-assignment]
3037
"""

0 commit comments

Comments
 (0)