Skip to content

Commit 37c324a

Browse files
committed
specify that type variable tuples and parameter specification should have variance
1 parent 4f470b0 commit 37c324a

26 files changed

Lines changed: 698 additions & 85 deletions
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
conformant = "Unsupported"
2+
conformance_automated = "Fail"
3+
errors_diff = """
4+
Line 40: Expected 1 errors
5+
Line 51: Expected 1 errors
6+
Line 22: Unexpected errors ['generics_paramspec_variance.py:22:1: error: Type `ContravariantParamSpec[object]` is not assignable to `ContravariantParamSpec[int]` (type parameter is invariant) [generics_variance_inference]']
7+
Line 31: Unexpected errors ['generics_paramspec_variance.py:31:1: error: Type `CovariantParamSpec[int]` is not assignable to `CovariantParamSpec[object]` (type parameter is invariant) [generics_variance_inference]']
8+
Line 33: Unexpected errors ['generics_paramspec_variance.py:33:7: error: `ParamSpec` `InP` does not support `covariant` or `contravariant` arguments [generics_typevartuple_basic]']
9+
Line 45: Unexpected errors ['generics_paramspec_variance.py:45:1: error: Type `ContravariantParamSpecOld[object]` is not assignable to `ContravariantParamSpecOld[int]` (type parameter is contravariant) [generics_variance_inference]']
10+
Line 47: Unexpected errors ['generics_paramspec_variance.py:47:8: error: `ParamSpec` `OutP` does not support `covariant` or `contravariant` arguments [generics_typevartuple_basic]']
11+
Line 58: Unexpected errors ['generics_paramspec_variance.py:58:1: error: Type `CovariantParamSpecOld[int]` is not assignable to `CovariantParamSpecOld[object]` (type parameter is covariant) [generics_variance_inference]']
12+
"""
13+
output = """
14+
generics_paramspec_variance.py:14:1: error: Type `InvariantParamSpec[int]` is not assignable to `InvariantParamSpec[object]` (type parameter is invariant) [generics_variance_inference]
15+
generics_paramspec_variance.py:15:1: error: Type `InvariantParamSpec[object]` is not assignable to `InvariantParamSpec[int]` (type parameter is invariant) [generics_variance_inference]
16+
generics_paramspec_variance.py:21:1: error: Type `ContravariantParamSpec[int]` is not assignable to `ContravariantParamSpec[object]` (type parameter is invariant) [generics_variance_inference]
17+
generics_paramspec_variance.py:22:1: error: Type `ContravariantParamSpec[object]` is not assignable to `ContravariantParamSpec[int]` (type parameter is invariant) [generics_variance_inference]
18+
generics_paramspec_variance.py:30:1: error: Type `CovariantParamSpec[object]` is not assignable to `CovariantParamSpec[int]` (type parameter is invariant) [generics_variance_inference]
19+
generics_paramspec_variance.py:31:1: error: Type `CovariantParamSpec[int]` is not assignable to `CovariantParamSpec[object]` (type parameter is invariant) [generics_variance_inference]
20+
generics_paramspec_variance.py:33:7: error: `ParamSpec` `InP` does not support `covariant` or `contravariant` arguments [generics_typevartuple_basic]
21+
generics_paramspec_variance.py:44:1: error: Type `ContravariantParamSpecOld[int]` is not assignable to `ContravariantParamSpecOld[object]` (type parameter is contravariant) [generics_variance_inference]
22+
generics_paramspec_variance.py:45:1: error: Type `ContravariantParamSpecOld[object]` is not assignable to `ContravariantParamSpecOld[int]` (type parameter is contravariant) [generics_variance_inference]
23+
generics_paramspec_variance.py:47:8: error: `ParamSpec` `OutP` does not support `covariant` or `contravariant` arguments [generics_typevartuple_basic]
24+
generics_paramspec_variance.py:57:1: error: Type `CovariantParamSpecOld[object]` is not assignable to `CovariantParamSpecOld[int]` (type parameter is covariant) [generics_variance_inference]
25+
generics_paramspec_variance.py:58:1: error: Type `CovariantParamSpecOld[int]` is not assignable to `CovariantParamSpecOld[object]` (type parameter is covariant) [generics_variance_inference]
26+
"""

‎conformance/results/basilisk/generics_typevartuple_basic.toml‎

Whitespace-only changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
conformant = "Unsupported"
2+
conformance_automated = "Fail"
3+
errors_diff = """
4+
Line 16: Expected 1 errors
5+
Line 35: Expected 1 errors
6+
Line 60: Expected 1 errors
7+
Line 71: Expected 1 errors
8+
Line 24: Unexpected errors ['generics_typevartuple_variance.py:24:1: error: Type `ContravariantTypeVarTuple[object]` is not assignable to `ContravariantTypeVarTuple[int]` (type parameter is contravariant) [generics_variance_inference]']
9+
Line 33: Unexpected errors ['generics_typevartuple_variance.py:33:1: error: Type `CovariantTypeVarTuple[int]` is not assignable to `CovariantTypeVarTuple[object]` (type parameter is covariant) [generics_variance_inference]']
10+
Line 54: Unexpected errors ['generics_typevartuple_variance.py:54:8: error: `TypeVarTuple` `InTs` does not support `covariant` or `contravariant` arguments [generics_typevartuple_basic]', 'generics_typevartuple_variance.py:54:8: error: Invalid `TypeVarTuple` parameters: `TypeVarTuple` does not support variance specification [generics_typevartuple_basic_3]']
11+
Line 65: Unexpected errors ['generics_typevartuple_variance.py:65:1: error: Type `ContravariantTypeVarTupleOld[object]` is not assignable to `ContravariantTypeVarTupleOld[int]` (type parameter is contravariant) [generics_variance_inference]']
12+
Line 68: Unexpected errors ['generics_typevartuple_variance.py:68:9: error: `TypeVarTuple` `OutTs` does not support `covariant` or `contravariant` arguments [generics_typevartuple_basic]', 'generics_typevartuple_variance.py:68:9: error: Invalid `TypeVarTuple` parameters: `TypeVarTuple` does not support variance specification [generics_typevartuple_basic_3]']
13+
Line 79: Unexpected errors ['generics_typevartuple_variance.py:79:1: error: Type `CovariantTypeVarTupleOld[int]` is not assignable to `CovariantTypeVarTupleOld[object]` (type parameter is covariant) [generics_variance_inference]']
14+
"""
15+
output = """
16+
generics_typevartuple_variance.py:14:1: error: Type `InvariantTypeVarTuple[int]` is not assignable to `InvariantTypeVarTuple[object]` (type parameter is invariant) [generics_variance_inference]
17+
generics_typevartuple_variance.py:15:1: error: Type `InvariantTypeVarTuple[object]` is not assignable to `InvariantTypeVarTuple[int]` (type parameter is invariant) [generics_variance_inference]
18+
generics_typevartuple_variance.py:23:1: error: Type `ContravariantTypeVarTuple[int]` is not assignable to `ContravariantTypeVarTuple[object]` (type parameter is contravariant) [generics_variance_inference]
19+
generics_typevartuple_variance.py:24:1: error: Type `ContravariantTypeVarTuple[object]` is not assignable to `ContravariantTypeVarTuple[int]` (type parameter is contravariant) [generics_variance_inference]
20+
generics_typevartuple_variance.py:32:1: error: Type `CovariantTypeVarTuple[object]` is not assignable to `CovariantTypeVarTuple[int]` (type parameter is covariant) [generics_variance_inference]
21+
generics_typevartuple_variance.py:33:1: error: Type `CovariantTypeVarTuple[int]` is not assignable to `CovariantTypeVarTuple[object]` (type parameter is covariant) [generics_variance_inference]
22+
generics_typevartuple_variance.py:36:1: error: Type `CovariantTypeVarTuple[object]` is not assignable to `CovariantTypeVarTuple[float]` (type parameter is covariant) [generics_variance_inference]
23+
generics_typevartuple_variance.py:37:1: error: Type `CovariantTypeVarTuple[object]` is not assignable to `CovariantTypeVarTuple[float]` (type parameter is covariant) [generics_variance_inference]
24+
generics_typevartuple_variance.py:50:1: error: Type `InvariantTypeVarTupleOld[int]` is not assignable to `InvariantTypeVarTupleOld[object]` (type parameter is invariant) [generics_variance_inference]
25+
generics_typevartuple_variance.py:51:1: error: Type `InvariantTypeVarTupleOld[object]` is not assignable to `InvariantTypeVarTupleOld[int]` (type parameter is invariant) [generics_variance_inference]
26+
generics_typevartuple_variance.py:54:8: error: `TypeVarTuple` `InTs` does not support `covariant` or `contravariant` arguments [generics_typevartuple_basic]
27+
generics_typevartuple_variance.py:54:8: error: Invalid `TypeVarTuple` parameters: `TypeVarTuple` does not support variance specification [generics_typevartuple_basic_3]
28+
generics_typevartuple_variance.py:64:1: error: Type `ContravariantTypeVarTupleOld[int]` is not assignable to `ContravariantTypeVarTupleOld[object]` (type parameter is contravariant) [generics_variance_inference]
29+
generics_typevartuple_variance.py:65:1: error: Type `ContravariantTypeVarTupleOld[object]` is not assignable to `ContravariantTypeVarTupleOld[int]` (type parameter is contravariant) [generics_variance_inference]
30+
generics_typevartuple_variance.py:68:9: error: `TypeVarTuple` `OutTs` does not support `covariant` or `contravariant` arguments [generics_typevartuple_basic]
31+
generics_typevartuple_variance.py:68:9: error: Invalid `TypeVarTuple` parameters: `TypeVarTuple` does not support variance specification [generics_typevartuple_basic_3]
32+
generics_typevartuple_variance.py:78:1: error: Type `CovariantTypeVarTupleOld[object]` is not assignable to `CovariantTypeVarTupleOld[int]` (type parameter is covariant) [generics_variance_inference]
33+
generics_typevartuple_variance.py:79:1: error: Type `CovariantTypeVarTupleOld[int]` is not assignable to `CovariantTypeVarTupleOld[object]` (type parameter is covariant) [generics_variance_inference]
34+
"""
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
conformant = "Unsupported"
2+
conformance_automated = "Fail"
3+
errors_diff = """
4+
Line 15: Expected 1 errors
5+
Line 30: Expected 1 errors
6+
Line 40: Expected 1 errors
7+
Line 51: Expected 1 errors
8+
Line 57: Expected 1 errors
9+
Line 31: Unexpected errors ['generics_paramspec_variance.py:31: error: Incompatible types in assignment (expression has type "CovariantParamSpec[[int]]", variable has type "CovariantParamSpec[[object]]") [assignment]']
10+
Line 33: Unexpected errors ['generics_paramspec_variance.py:33: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc]']
11+
Line 47: Unexpected errors ['generics_paramspec_variance.py:47: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc]']
12+
Line 58: Unexpected errors ['generics_paramspec_variance.py:58: error: Incompatible types in assignment (expression has type "CovariantParamSpecOld[[int]]", variable has type "CovariantParamSpecOld[[object]]") [assignment]']
13+
"""
14+
output = """
15+
generics_paramspec_variance.py:14: error: Incompatible types in assignment (expression has type "InvariantParamSpec[[int]]", variable has type "InvariantParamSpec[[object]]") [assignment]
16+
generics_paramspec_variance.py:21: error: Incompatible types in assignment (expression has type "ContravariantParamSpec[[int]]", variable has type "ContravariantParamSpec[[object]]") [assignment]
17+
generics_paramspec_variance.py:31: error: Incompatible types in assignment (expression has type "CovariantParamSpec[[int]]", variable has type "CovariantParamSpec[[object]]") [assignment]
18+
generics_paramspec_variance.py:33: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc]
19+
generics_paramspec_variance.py:44: error: Incompatible types in assignment (expression has type "ContravariantParamSpecOld[[int]]", variable has type "ContravariantParamSpecOld[[object]]") [assignment]
20+
generics_paramspec_variance.py:47: error: The variance and bound arguments to ParamSpec do not have defined semantics yet [misc]
21+
generics_paramspec_variance.py:58: error: Incompatible types in assignment (expression has type "CovariantParamSpecOld[[int]]", variable has type "CovariantParamSpecOld[[object]]") [assignment]
22+
"""

‎conformance/results/mypy/generics_typevartuple_basic.toml‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ notes = """
33
Does not enforce that tuples captured by `TypeVarTuple` are same length.
44
"""
55
output = """
6-
generics_typevartuple_basic.py:42: error: Argument 1 to "Array" has incompatible type "Height"; expected "tuple[Height, Width]" [arg-type]
7-
generics_typevartuple_basic.py:43: error: Argument 1 to "Array" has incompatible type "tuple[Batch, Width]"; expected "tuple[Batch, Height, Width]" [arg-type]
8-
generics_typevartuple_basic.py:45: error: Argument 1 to "Array" has incompatible type "tuple[Time, Batch, Width, Height]"; expected "tuple[Time, Batch, Height, Width]" [arg-type]
9-
generics_typevartuple_basic.py:52: error: Free type variable expected in Generic[...] [misc]
10-
generics_typevartuple_basic.py:53: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type]
11-
generics_typevartuple_basic.py:56: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type]
12-
generics_typevartuple_basic.py:59: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type]
13-
generics_typevartuple_basic.py:65: error: Unexpected keyword argument "covariant" for "TypeVarTuple" [misc]
6+
generics_typevartuple_basic.py:43: error: Argument 1 to "Array" has incompatible type "Height"; expected "tuple[Height, Width]" [arg-type]
7+
generics_typevartuple_basic.py:44: error: Argument 1 to "Array" has incompatible type "tuple[Batch, Width]"; expected "tuple[Batch, Height, Width]" [arg-type]
8+
generics_typevartuple_basic.py:46: error: Argument 1 to "Array" has incompatible type "tuple[Time, Batch, Width, Height]"; expected "tuple[Time, Batch, Height, Width]" [arg-type]
9+
generics_typevartuple_basic.py:53: error: Free type variable expected in Generic[...] [misc]
10+
generics_typevartuple_basic.py:54: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type]
11+
generics_typevartuple_basic.py:57: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type]
12+
generics_typevartuple_basic.py:60: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type]
1413
generics_typevartuple_basic.py:66: error: Too many positional arguments for "TypeVarTuple" [misc]
1514
generics_typevartuple_basic.py:67: error: Unexpected keyword argument "bound" for "TypeVarTuple" [misc]
1615
generics_typevartuple_basic.py:100: error: Cannot infer value of type parameter "Shape" of "multiply" [misc]
1716
generics_typevartuple_basic.py:101: error: Cannot infer value of type parameter "Shape" of "multiply" [misc]
1817
generics_typevartuple_basic.py:107: error: Can only use one type var tuple in a class def [misc]
18+
generics_typevartuple_basic.py:111: error: Can only use one type var tuple in a class def [misc]
1919
"""
2020
conformance_automated = "Fail"
2121
errors_diff = """
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
conformant = "Unsupported"
2+
conformance_automated = "Fail"
3+
errors_diff = """
4+
Line 14: Expected 1 errors
5+
Line 16: Expected 1 errors
6+
Line 50: Expected 1 errors
7+
Line 60: Expected 1 errors
8+
Line 64: Expected 1 errors
9+
Line 71: Expected 1 errors
10+
Line 24: Unexpected errors ['generics_typevartuple_variance.py:24: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTuple[object]", variable has type "ContravariantTypeVarTuple[int]") [assignment]']
11+
Line 54: Unexpected errors ['generics_typevartuple_variance.py:54: error: Unexpected keyword argument "contravariant" for "TypeVarTuple" [misc]']
12+
Line 65: Unexpected errors ['generics_typevartuple_variance.py:65: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTupleOld[object]", variable has type "ContravariantTypeVarTupleOld[int]") [assignment]']
13+
Line 68: Unexpected errors ['generics_typevartuple_variance.py:68: error: Unexpected keyword argument "covariant" for "TypeVarTuple" [misc]']
14+
"""
15+
output = """
16+
generics_typevartuple_variance.py:15: error: Incompatible types in assignment (expression has type "InvariantTypeVarTuple[object]", variable has type "InvariantTypeVarTuple[int]") [assignment]
17+
generics_typevartuple_variance.py:23: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTuple[int]", variable has type "ContravariantTypeVarTuple[object, object]") [assignment]
18+
generics_typevartuple_variance.py:24: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTuple[object]", variable has type "ContravariantTypeVarTuple[int]") [assignment]
19+
generics_typevartuple_variance.py:32: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[object]", variable has type "CovariantTypeVarTuple[int]") [assignment]
20+
generics_typevartuple_variance.py:35: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[int, object]", variable has type "CovariantTypeVarTuple[float, float]") [assignment]
21+
generics_typevartuple_variance.py:36: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[object, int]", variable has type "CovariantTypeVarTuple[float, float]") [assignment]
22+
generics_typevartuple_variance.py:37: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[object, object]", variable has type "CovariantTypeVarTuple[float, float]") [assignment]
23+
generics_typevartuple_variance.py:51: error: Incompatible types in assignment (expression has type "InvariantTypeVarTupleOld[object]", variable has type "InvariantTypeVarTupleOld[int]") [assignment]
24+
generics_typevartuple_variance.py:54: error: Unexpected keyword argument "contravariant" for "TypeVarTuple" [misc]
25+
generics_typevartuple_variance.py:65: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTupleOld[object]", variable has type "ContravariantTypeVarTupleOld[int]") [assignment]
26+
generics_typevartuple_variance.py:68: error: Unexpected keyword argument "covariant" for "TypeVarTuple" [misc]
27+
generics_typevartuple_variance.py:78: error: Incompatible types in assignment (expression has type "CovariantTypeVarTupleOld[object]", variable has type "CovariantTypeVarTupleOld[int]") [assignment]
28+
"""
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
conformant = "Unsupported"
2+
conformance_automated = "Fail"
3+
errors_diff = """
4+
Line 40: Expected 1 errors
5+
Line 51: Expected 1 errors
6+
Line 19: Unexpected errors ['./generics_paramspec_variance.py:19:23: Traceback (most recent call last):', './generics_paramspec_variance.py:19:4: Traceback (most recent call last):']
7+
Line 22: Unexpected errors ['./generics_paramspec_variance.py:22:38: Traceback (most recent call last):']
8+
Line 31: Unexpected errors ['./generics_paramspec_variance.py:31:38: Traceback (most recent call last):']
9+
Line 45: Unexpected errors ['./generics_paramspec_variance.py:45:45: Traceback (most recent call last):']
10+
Line 58: Unexpected errors ['./generics_paramspec_variance.py:58:45: Traceback (most recent call last):']
11+
"""
12+
output = """
13+
./generics_paramspec_variance.py:14:41: Traceback (most recent call last):
14+
./generics_paramspec_variance.py:15:38: Traceback (most recent call last):
15+
./generics_paramspec_variance.py:19:23: Traceback (most recent call last):
16+
./generics_paramspec_variance.py:19:4: Traceback (most recent call last):
17+
./generics_paramspec_variance.py:21:41: Traceback (most recent call last):
18+
./generics_paramspec_variance.py:22:38: Traceback (most recent call last):
19+
./generics_paramspec_variance.py:30:35: Traceback (most recent call last):
20+
./generics_paramspec_variance.py:31:38: Traceback (most recent call last):
21+
./generics_paramspec_variance.py:44:48: Traceback (most recent call last):
22+
./generics_paramspec_variance.py:45:45: Traceback (most recent call last):
23+
./generics_paramspec_variance.py:57:42: Traceback (most recent call last):
24+
./generics_paramspec_variance.py:58:45: Traceback (most recent call last):
25+
"""

0 commit comments

Comments
 (0)