Skip to content

Commit 54ad5e1

Browse files
committed
specify that parameter specification should have variance
1 parent 418094f commit 54ad5e1

File tree

8 files changed

+172
-19
lines changed

8 files changed

+172
-19
lines changed

conformance/results/mypy/generics_paramspec_semantics.toml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
conformant = "Pass"
1+
conformant = "Partial"
2+
notes = "parameter specification variance not supported"
23
output = """
34
generics_paramspec_semantics.py:26: error: Unexpected keyword argument "a" [call-arg]
45
generics_paramspec_semantics.py:26: error: Unexpected keyword argument "b" [call-arg]
@@ -11,7 +12,25 @@ generics_paramspec_semantics.py:127: error: Argument 1 to "expects_int_first" ha
1112
generics_paramspec_semantics.py:127: note: This is likely because "one" has named arguments: "x". Consider marking them positional-only
1213
generics_paramspec_semantics.py:132: error: Argument 1 to "expects_int_first" has incompatible type "def two(*, x: int) -> int"; expected "def (int, /, *, x: int) -> int" [arg-type]
1314
generics_paramspec_semantics.py:137: error: Argument 1 to "expects_int_first" has incompatible type "def three(**kwargs: int) -> int"; expected "def (int, /, **kwargs: int) -> int" [arg-type]
15+
generics_paramspec_semantics.py:151: error: Incompatible types in assignment (expression has type "ContravariantParamSpec[[int]]", variable has type "ContravariantParamSpec[[object]]") [assignment]
16+
generics_paramspec_semantics.py:155: error: Missing return statement [empty-body]
17+
generics_paramspec_semantics.py:158: error: Incompatible types in assignment (expression has type "CovariantParamSpec[[int]]", variable has type "CovariantParamSpec[[object]]") [assignment]
18+
generics_paramspec_semantics.py:161: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc]
19+
generics_paramspec_semantics.py:165: error: Missing return statement [empty-body]
20+
generics_paramspec_semantics.py:169: error: Incompatible types in assignment (expression has type "ContravariantParamSpecOld[[int]]", variable has type "ContravariantParamSpecOld[[object]]") [assignment]
21+
generics_paramspec_semantics.py:171: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc]
22+
generics_paramspec_semantics.py:175: error: Missing return statement [empty-body]
23+
generics_paramspec_semantics.py:178: error: Incompatible types in assignment (expression has type "ContravariantParamSpecOld[[int]]", variable has type "ContravariantParamSpecOld[[object]]") [assignment]
1424
"""
15-
conformance_automated = "Pass"
25+
conformance_automated = "Fail"
1626
errors_diff = """
27+
Line 159: Expected 1 errors
28+
Line 174: Expected 1 errors
29+
Line 179: Expected 1 errors
30+
Line 155: Unexpected errors ['generics_paramspec_semantics.py:155: error: Missing return statement [empty-body]']
31+
Line 158: Unexpected errors ['generics_paramspec_semantics.py:158: error: Incompatible types in assignment (expression has type "CovariantParamSpec[[int]]", variable has type "CovariantParamSpec[[object]]") [assignment]']
32+
Line 161: Unexpected errors ['generics_paramspec_semantics.py:161: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc]']
33+
Line 171: Unexpected errors ['generics_paramspec_semantics.py:171: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc]']
34+
Line 175: Unexpected errors ['generics_paramspec_semantics.py:175: error: Missing return statement [empty-body]']
35+
Line 178: Unexpected errors ['generics_paramspec_semantics.py:178: error: Incompatible types in assignment (expression has type "ContravariantParamSpecOld[[int]]", variable has type "ContravariantParamSpecOld[[object]]") [assignment]']
1736
"""

conformance/results/pyrefly/generics_paramspec_semantics.toml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
conformant = "Pass"
2-
conformance_automated = "Pass"
1+
conformant = "Partial"
2+
notes = "parameter specification variance not supported"
3+
conformance_automated = "Fail"
34
errors_diff = """
5+
Line 151: Expected 1 errors
6+
Line 165: Expected 1 errors
7+
Line 174: Expected 1 errors
8+
Line 150: Unexpected errors ['`ContravariantParamSpec[[object]]` is not assignable to `ContravariantParamSpec[[int]]` [bad-assignment]']
9+
Line 161: Unexpected errors ['Unexpected keyword argument `contravariant` to ParamSpec [invalid-param-spec]']
10+
Line 168: Unexpected errors ['`ContravariantParamSpecOld[[object]]` is not assignable to `ContravariantParamSpecOld[[int]]` [bad-assignment]']
11+
Line 171: Unexpected errors ['Unexpected keyword argument `covariant` to ParamSpec [invalid-param-spec]']
12+
Line 178: Unexpected errors ['`ContravariantParamSpecOld[[int]]` is not assignable to `ContravariantParamSpecOld[[object]]` [bad-assignment]']
413
"""
514
output = """
615
ERROR generics_paramspec_semantics.py:26:4-5: Expected argument `a` to be positional [unexpected-keyword]
@@ -14,4 +23,12 @@ ERROR generics_paramspec_semantics.py:120:4-5: Argument `Literal[1]` is not assi
1423
ERROR generics_paramspec_semantics.py:127:1-19: Argument `(x: str) -> int` is not assignable to parameter `x` with type `(int, ParamSpec(@_)) -> int` in function `expects_int_first` [bad-argument-type]
1524
ERROR generics_paramspec_semantics.py:132:1-19: Argument `(*, x: int) -> int` is not assignable to parameter `x` with type `(int, ParamSpec(@_)) -> int` in function `expects_int_first` [bad-argument-type]
1625
ERROR generics_paramspec_semantics.py:137:1-19: Argument `(**kwargs: int) -> int` is not assignable to parameter `x` with type `(int, ParamSpec(@_)) -> int` in function `expects_int_first` [bad-argument-type]
26+
ERROR generics_paramspec_semantics.py:150:39-45: `ContravariantParamSpec[[object]]` is not assignable to `ContravariantParamSpec[[int]]` [bad-assignment]
27+
ERROR generics_paramspec_semantics.py:159:11-18: `CovariantParamSpec[[object]]` is not assignable to variable `out_int` with type `CovariantParamSpec[[int]]` [bad-assignment]
28+
ERROR generics_paramspec_semantics.py:161:24-42: Unexpected keyword argument `contravariant` to ParamSpec [invalid-param-spec]
29+
ERROR generics_paramspec_semantics.py:168:46-56: `ContravariantParamSpecOld[[object]]` is not assignable to `ContravariantParamSpecOld[[int]]` [bad-assignment]
30+
ERROR generics_paramspec_semantics.py:169:14-24: `ContravariantParamSpecOld[[int]]` is not assignable to variable `in_obj_old` with type `ContravariantParamSpecOld[[object]]` [bad-assignment]
31+
ERROR generics_paramspec_semantics.py:171:26-40: Unexpected keyword argument `covariant` to ParamSpec [invalid-param-spec]
32+
ERROR generics_paramspec_semantics.py:178:50-61: `ContravariantParamSpecOld[[int]]` is not assignable to `ContravariantParamSpecOld[[object]]` [bad-assignment]
33+
ERROR generics_paramspec_semantics.py:179:15-26: `ContravariantParamSpecOld[[object]]` is not assignable to variable `out_int_old` with type `ContravariantParamSpecOld[[int]]` [bad-assignment]
1734
"""

conformance/results/pyright/generics_paramspec_semantics.toml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
conformant = "Pass"
1+
conformant = "Partial"
22
notes = """
33
Constraint solver doesn't find common type for two signatures captured by a single ParamSpec (allowed).
4+
parameter specification variance not supported
45
"""
56
output = """
67
generics_paramspec_semantics.py:26:6 - error: Expected 2 more positional arguments (reportCallIssue)
@@ -30,7 +31,41 @@ generics_paramspec_semantics.py:132:2 - error: Argument of type "(*, x: int) ->
3031
generics_paramspec_semantics.py:137:2 - error: Argument of type "(**kwargs: int) -> int" cannot be assigned to parameter "x" of type "(int, **P@expects_int_first) -> int" in function "expects_int_first"
3132
  Type "(**kwargs: int) -> int" is not assignable to type "(int, **P@expects_int_first) -> int"
3233
    Function accepts too many positional parameters; expected 0 but received 1 (reportArgumentType)
34+
generics_paramspec_semantics.py:150:39 - error: Type "ContravariantParamSpec[(object)]" is not assignable to declared type "ContravariantParamSpec[(int)]"
35+
  "ContravariantParamSpec[(object)]" is not assignable to "ContravariantParamSpec[(int)]"
36+
    Type parameter "InP@ContravariantParamSpec" is invariant, but "(object)" is not the same as "(int)" (reportAssignmentType)
37+
generics_paramspec_semantics.py:151:10 - error: Type "ContravariantParamSpec[(int)]" is not assignable to declared type "ContravariantParamSpec[(object)]"
38+
  "ContravariantParamSpec[(int)]" is not assignable to "ContravariantParamSpec[(object)]"
39+
    Type parameter "InP@ContravariantParamSpec" is invariant, but "(int)" is not the same as "(object)" (reportAssignmentType)
40+
generics_paramspec_semantics.py:158:39 - error: Type "CovariantParamSpec[(int)]" is not assignable to declared type "CovariantParamSpec[(object)]"
41+
  "CovariantParamSpec[(int)]" is not assignable to "CovariantParamSpec[(object)]"
42+
    Type parameter "OutP@CovariantParamSpec" is invariant, but "(int)" is not the same as "(object)" (reportAssignmentType)
43+
generics_paramspec_semantics.py:159:11 - error: Type "CovariantParamSpec[(object)]" is not assignable to declared type "CovariantParamSpec[(int)]"
44+
  "CovariantParamSpec[(object)]" is not assignable to "CovariantParamSpec[(int)]"
45+
    Type parameter "OutP@CovariantParamSpec" is invariant, but "(object)" is not the same as "(int)" (reportAssignmentType)
46+
generics_paramspec_semantics.py:161:24 - error: "contravariant" is unknown parameter to ParamSpec (reportGeneralTypeIssues)
47+
generics_paramspec_semantics.py:168:46 - error: Type "ContravariantParamSpecOld[(object)]" is not assignable to declared type "ContravariantParamSpecOld[(int)]"
48+
  "ContravariantParamSpecOld[(object)]" is not assignable to "ContravariantParamSpecOld[(int)]"
49+
    Type parameter "InP@ContravariantParamSpecOld" is invariant, but "(object)" is not the same as "(int)" (reportAssignmentType)
50+
generics_paramspec_semantics.py:169:14 - error: Type "ContravariantParamSpecOld[(int)]" is not assignable to declared type "ContravariantParamSpecOld[(object)]"
51+
  "ContravariantParamSpecOld[(int)]" is not assignable to "ContravariantParamSpecOld[(object)]"
52+
    Type parameter "InP@ContravariantParamSpecOld" is invariant, but "(int)" is not the same as "(object)" (reportAssignmentType)
53+
generics_paramspec_semantics.py:171:26 - error: "covariant" is unknown parameter to ParamSpec (reportGeneralTypeIssues)
54+
generics_paramspec_semantics.py:178:50 - error: Type "ContravariantParamSpecOld[(int)]" is not assignable to declared type "ContravariantParamSpecOld[(object)]"
55+
  "ContravariantParamSpecOld[(int)]" is not assignable to "ContravariantParamSpecOld[(object)]"
56+
    Type parameter "InP@ContravariantParamSpecOld" is invariant, but "(int)" is not the same as "(object)" (reportAssignmentType)
57+
generics_paramspec_semantics.py:179:15 - error: Type "ContravariantParamSpecOld[(object)]" is not assignable to declared type "ContravariantParamSpecOld[(int)]"
58+
  "ContravariantParamSpecOld[(object)]" is not assignable to "ContravariantParamSpecOld[(int)]"
59+
    Type parameter "InP@ContravariantParamSpecOld" is invariant, but "(object)" is not the same as "(int)" (reportAssignmentType)
3360
"""
34-
conformance_automated = "Pass"
61+
conformance_automated = "Fail"
3562
errors_diff = """
63+
Line 165: Expected 1 errors
64+
Line 174: Expected 1 errors
65+
Line 150: Unexpected errors ['generics_paramspec_semantics.py:150:39 - error: Type "ContravariantParamSpec[(object)]" is not assignable to declared type "ContravariantParamSpec[(int)]"']
66+
Line 158: Unexpected errors ['generics_paramspec_semantics.py:158:39 - error: Type "CovariantParamSpec[(int)]" is not assignable to declared type "CovariantParamSpec[(object)]"']
67+
Line 161: Unexpected errors ['generics_paramspec_semantics.py:161:24 - error: "contravariant" is unknown parameter to ParamSpec (reportGeneralTypeIssues)']
68+
Line 168: Unexpected errors ['generics_paramspec_semantics.py:168:46 - error: Type "ContravariantParamSpecOld[(object)]" is not assignable to declared type "ContravariantParamSpecOld[(int)]"']
69+
Line 171: Unexpected errors ['generics_paramspec_semantics.py:171:26 - error: "covariant" is unknown parameter to ParamSpec (reportGeneralTypeIssues)']
70+
Line 178: Unexpected errors ['generics_paramspec_semantics.py:178:50 - error: Type "ContravariantParamSpecOld[(int)]" is not assignable to declared type "ContravariantParamSpecOld[(object)]"']
3671
"""

conformance/results/results.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,11 @@ <h3>Python Type System Conformance Test Results</h3>
322322
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Incorrectly allows using `*args: P.args` and `**kwargs: P.kwargs` when `P` has not been put into scope by any other parameter annotation or enclosing scope.</p></span></div></th>
323323
</tr>
324324
<tr><th class="column col1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;generics_paramspec_semantics</th>
325-
<th class="column col2 conformant">Pass</th>
326-
<th class="column col2 conformant"><div class="hover-text">Pass*<span class="tooltip-text" id="bottom"><p>Constraint solver doesn't find common type for two signatures captured by a single ParamSpec (allowed).</p></span></div></th>
327-
<th class="column col2 conformant">Pass</th>
328-
<th class="column col2 conformant">Pass</th>
329-
<th class="column col2 conformant">Pass</th>
325+
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>parameter specification variance not supported</p></span></div></th>
326+
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Constraint solver doesn't find common type for two signatures captured by a single ParamSpec (allowed).</p><p>parameter specification variance not supported</p></span></div></th>
327+
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>parameter specification variance not supported</p></span></div></th>
328+
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>parameter specification variance not supported</p></span></div></th>
329+
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>parameter specification variance not supported</p></span></div></th>
330330
</tr>
331331
<tr><th class="column col1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;generics_paramspec_specialization</th>
332332
<th class="column col2 conformant">Pass</th>

conformance/results/ty/generics_paramspec_semantics.toml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
conformance_automated = "Pass"
1+
conformant = "Partial"
2+
notes = "parameter specification variance not supported"
3+
conformance_automated = "Fail"
24
errors_diff = """
5+
Line 151: Expected 1 errors
6+
Line 159: Expected 1 errors
7+
Line 169: Expected 1 errors
8+
Line 179: Expected 1 errors
9+
Line 155: Unexpected errors ['generics_paramspec_semantics.py:155:20: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `(**OutP@CovariantParamSpec) -> None`']
10+
Line 161: Unexpected errors ['generics_paramspec_semantics.py:161:7: error[invalid-paramspec] The variance and bound arguments for `ParamSpec` do not have defined semantics yet']
11+
Line 163: Unexpected errors ['generics_paramspec_semantics.py:163:33: error[invalid-argument-type] `ParamSpec` is not a valid argument to `Generic`']
12+
Line 164: Unexpected errors ['generics_paramspec_semantics.py:164:27: error[invalid-type-form] Variable of type `ParamSpecArgs` is not allowed in a type expression', 'generics_paramspec_semantics.py:164:47: error[invalid-type-form] Variable of type `ParamSpecKwargs` is not allowed in a type expression']
13+
Line 171: Unexpected errors ['generics_paramspec_semantics.py:171:8: error[invalid-paramspec] The variance and bound arguments for `ParamSpec` do not have defined semantics yet']
14+
Line 173: Unexpected errors ['generics_paramspec_semantics.py:173:29: error[invalid-argument-type] `ParamSpec` is not a valid argument to `Generic`']
15+
Line 175: Unexpected errors ['generics_paramspec_semantics.py:175:24: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `(...) -> Unknown`', 'generics_paramspec_semantics.py:175:33: error[invalid-type-form] Variable of type `ParamSpec` is not allowed in a type expression', 'generics_paramspec_semantics.py:175:33: error[invalid-type-form] The first argument to `Callable` must be either a list of types, ParamSpec, Concatenate, or `...`']
316
"""
417
output = """
518
generics_paramspec_semantics.py:26:4: error[positional-only-parameter-as-kwarg] Positional-only parameter 1 (`a`) passed as keyword argument
@@ -13,4 +26,19 @@ generics_paramspec_semantics.py:120:4: error[invalid-argument-type] Argument is
1326
generics_paramspec_semantics.py:127:1: error[invalid-argument-type] Argument to function `expects_int_first` is incorrect: Expected `(int, /, *args: Unknown, **kwargs: Unknown) -> int`, found `def one(x: str) -> int`
1427
generics_paramspec_semantics.py:132:1: error[invalid-argument-type] Argument to function `expects_int_first` is incorrect: Expected `(int, /, *args: Unknown, **kwargs: Unknown) -> int`, found `def two(*, x: int) -> int`
1528
generics_paramspec_semantics.py:137:1: error[invalid-argument-type] Argument to function `expects_int_first` is incorrect: Expected `(int, /, *args: Unknown, **kwargs: Unknown) -> int`, found `def three(**kwargs: int) -> int`
29+
generics_paramspec_semantics.py:155:20: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `(**OutP@CovariantParamSpec) -> None`
30+
generics_paramspec_semantics.py:161:7: error[invalid-paramspec] The variance and bound arguments for `ParamSpec` do not have defined semantics yet
31+
generics_paramspec_semantics.py:163:33: error[invalid-argument-type] `ParamSpec` is not a valid argument to `Generic`
32+
generics_paramspec_semantics.py:164:27: error[invalid-type-form] Variable of type `ParamSpecArgs` is not allowed in a type expression
33+
generics_paramspec_semantics.py:164:47: error[invalid-type-form] Variable of type `ParamSpecKwargs` is not allowed in a type expression
34+
generics_paramspec_semantics.py:165:24: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `(...) -> Unknown`
35+
generics_paramspec_semantics.py:165:33: error[invalid-type-form] Variable of type `ParamSpec` is not allowed in a type expression
36+
generics_paramspec_semantics.py:165:33: error[invalid-type-form] The first argument to `Callable` must be either a list of types, ParamSpec, Concatenate, or `...`
37+
generics_paramspec_semantics.py:171:8: error[invalid-paramspec] The variance and bound arguments for `ParamSpec` do not have defined semantics yet
38+
generics_paramspec_semantics.py:173:29: error[invalid-argument-type] `ParamSpec` is not a valid argument to `Generic`
39+
generics_paramspec_semantics.py:174:27: error[invalid-type-form] Variable of type `ParamSpecArgs` is not allowed in a type expression
40+
generics_paramspec_semantics.py:174:48: error[invalid-type-form] Variable of type `ParamSpecKwargs` is not allowed in a type expression
41+
generics_paramspec_semantics.py:175:24: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `(...) -> Unknown`
42+
generics_paramspec_semantics.py:175:33: error[invalid-type-form] Variable of type `ParamSpec` is not allowed in a type expression
43+
generics_paramspec_semantics.py:175:33: error[invalid-type-form] The first argument to `Callable` must be either a list of types, ParamSpec, Concatenate, or `...`
1644
"""

0 commit comments

Comments
 (0)