Skip to content

Commit 7a4c793

Browse files
committed
fixup! specify that type variable tuple should have variance
1 parent cf0165f commit 7a4c793

16 files changed

Lines changed: 284 additions & 234 deletions

conformance/results/mypy/generics_typevartuple_basic.toml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@ 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: Too many positional arguments for "TypeVarTuple" [misc]
14-
generics_typevartuple_basic.py:66: error: Unexpected keyword argument "bound" for "TypeVarTuple" [misc]
15-
generics_typevartuple_basic.py:99: error: Cannot infer value of type parameter "Shape" of "multiply" [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]
13+
generics_typevartuple_basic.py:66: error: Too many positional arguments for "TypeVarTuple" [misc]
14+
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]
17-
generics_typevartuple_basic.py:106: error: Can only use one type var tuple in a class def [misc]
16+
generics_typevartuple_basic.py:101: error: Cannot infer value of type parameter "Shape" of "multiply" [misc]
17+
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]
1819
"""
1920
conformance_automated = "Fail"
2021
errors_diff = """
21-
Line 90: Expected 1 errors
22+
Line 91: Expected 1 errors
2223
"""
Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
conformant = "Unsupported"
22
conformance_automated = "Fail"
33
errors_diff = """
4-
Line 13: Expected 1 errors
5-
Line 15: Expected 1 errors
6-
Line 35: Expected 1 errors
7-
Line 46: Expected 1 errors
4+
Line 14: Expected 1 errors
5+
Line 16: Expected 1 errors
6+
Line 36: Expected 1 errors
87
Line 50: Expected 1 errors
9-
Line 57: Expected 1 errors
10-
Line 23: Unexpected errors ['generics_typevartuple_variance.py:23: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTuple[object]", variable has type "ContravariantTypeVarTuple[int]") [assignment]']
11-
Line 33: Unexpected errors ['generics_typevartuple_variance.py:33: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[int, object]", variable has type "CovariantTypeVarTuple[float, float]") [assignment]']
12-
Line 39: Unexpected errors ['generics_typevartuple_variance.py:39: error: Unexpected keyword argument "contravariant" for "TypeVarTuple" [misc]']
13-
Line 51: Unexpected errors ['generics_typevartuple_variance.py:51: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTupleOld[object]", variable has type "ContravariantTypeVarTupleOld[int]") [assignment]']
14-
Line 53: Unexpected errors ['generics_typevartuple_variance.py:53: error: Unexpected keyword argument "covariant" for "TypeVarTuple" [misc]']
8+
Line 60: Expected 1 errors
9+
Line 64: Expected 1 errors
10+
Line 71: Expected 1 errors
11+
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]']
12+
Line 34: Unexpected errors ['generics_typevartuple_variance.py:34: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[int, object]", variable has type "CovariantTypeVarTuple[float, float]") [assignment]']
13+
Line 54: Unexpected errors ['generics_typevartuple_variance.py:54: error: Unexpected keyword argument "contravariant" for "TypeVarTuple" [misc]']
14+
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]']
15+
Line 68: Unexpected errors ['generics_typevartuple_variance.py:68: error: Unexpected keyword argument "covariant" for "TypeVarTuple" [misc]']
1516
"""
1617
output = """
17-
generics_typevartuple_variance.py:14: error: Incompatible types in assignment (expression has type "InvariantTypeVarTuple[object]", variable has type "InvariantTypeVarTuple[int]") [assignment]
18-
generics_typevartuple_variance.py:22: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTuple[int]", variable has type "ContravariantTypeVarTuple[object, object]") [assignment]
19-
generics_typevartuple_variance.py:23: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTuple[object]", variable has type "ContravariantTypeVarTuple[int]") [assignment]
20-
generics_typevartuple_variance.py:31: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[object]", variable has type "CovariantTypeVarTuple[int]") [assignment]
21-
generics_typevartuple_variance.py:33: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[int, object]", variable has type "CovariantTypeVarTuple[float, float]") [assignment]
22-
generics_typevartuple_variance.py:39: error: Unexpected keyword argument "contravariant" for "TypeVarTuple" [misc]
23-
generics_typevartuple_variance.py:51: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTupleOld[object]", variable has type "ContravariantTypeVarTupleOld[int]") [assignment]
24-
generics_typevartuple_variance.py:53: error: Unexpected keyword argument "covariant" for "TypeVarTuple" [misc]
25-
generics_typevartuple_variance.py:64: error: Incompatible types in assignment (expression has type "CovariantTypeVarTupleOld[object]", variable has type "CovariantTypeVarTupleOld[int]") [assignment]
18+
generics_typevartuple_variance.py:15: error: Incompatible types in assignment (expression has type "InvariantTypeVarTuple[object]", variable has type "InvariantTypeVarTuple[int]") [assignment]
19+
generics_typevartuple_variance.py:23: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTuple[int]", variable has type "ContravariantTypeVarTuple[object, object]") [assignment]
20+
generics_typevartuple_variance.py:24: error: Incompatible types in assignment (expression has type "ContravariantTypeVarTuple[object]", variable has type "ContravariantTypeVarTuple[int]") [assignment]
21+
generics_typevartuple_variance.py:32: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[object]", variable has type "CovariantTypeVarTuple[int]") [assignment]
22+
generics_typevartuple_variance.py:34: error: Incompatible types in assignment (expression has type "CovariantTypeVarTuple[int, 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]
2628
"""

conformance/results/pycroscope/generics_typevartuple_basic.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
conformance_automated = "Pass"
1+
conformance_automated = "Fail"
22
errors_diff = """
3+
Line 111: Expected 1 errors
34
"""
45
output = """
5-
./generics_typevartuple_basic.py:42:33: Incompatible argument type for shape: expected tuple[*tuple[Shape, ...]] but got NewType('Height', int) [incompatible_argument]
6-
./generics_typevartuple_basic.py:43:0: Incompatible assignment: expected ./generics_typevartuple_basic.py.Array[NewType('Batch', int), NewType('Height', int), NewType('Width', int)], got ./generics_typevartuple_basic.py.Array~[NewType('Batch', int), NewType('Width', int)] [incompatible_assignment]
7-
./generics_typevartuple_basic.py:44:0: Incompatible assignment: expected ./generics_typevartuple_basic.py.Array[NewType('Time', int), NewType('Batch', int), NewType('Height', int), NewType('Width', int)], got ./generics_typevartuple_basic.py.Array~[NewType('Time', int), NewType('Batch', int), NewType('Width', int), NewType('Height', int)] [incompatible_assignment]
8-
./generics_typevartuple_basic.py:52:21: TypeVarTuple must be unpacked [invalid_base]
9-
./generics_typevartuple_basic.py:53:30: TypeVarTuple must be unpacked [invalid_annotation]
10-
./generics_typevartuple_basic.py:56:27: TypeVarTuple must be unpacked [invalid_annotation]
11-
./generics_typevartuple_basic.py:59:17: TypeVarTuple must be unpacked [invalid_annotation]
12-
./generics_typevartuple_basic.py:65:6: In call to typing.TypeVarTuple: Got an unexpected keyword argument 'covariant' [incompatible_call]
6+
./generics_typevartuple_basic.py:43:33: Incompatible argument type for shape: expected tuple[*tuple[Shape, ...]] but got NewType('Height', int) [incompatible_argument]
7+
./generics_typevartuple_basic.py:44:0: Incompatible assignment: expected ./generics_typevartuple_basic.py.Array[NewType('Batch', int), NewType('Height', int), NewType('Width', int)], got ./generics_typevartuple_basic.py.Array~[NewType('Batch', int), NewType('Width', int)] [incompatible_assignment]
8+
./generics_typevartuple_basic.py:45:0: Incompatible assignment: expected ./generics_typevartuple_basic.py.Array[NewType('Time', int), NewType('Batch', int), NewType('Height', int), NewType('Width', int)], got ./generics_typevartuple_basic.py.Array~[NewType('Time', int), NewType('Batch', int), NewType('Width', int), NewType('Height', int)] [incompatible_assignment]
9+
./generics_typevartuple_basic.py:53:21: TypeVarTuple must be unpacked [invalid_base]
10+
./generics_typevartuple_basic.py:54:30: TypeVarTuple must be unpacked [invalid_annotation]
11+
./generics_typevartuple_basic.py:57:27: TypeVarTuple must be unpacked [invalid_annotation]
12+
./generics_typevartuple_basic.py:60:17: TypeVarTuple must be unpacked [invalid_annotation]
1313
./generics_typevartuple_basic.py:66:6: In call to typing.TypeVarTuple: Takes 1 positional arguments but 3 were given [incompatible_call]
1414
./generics_typevartuple_basic.py:67:6: In call to typing.TypeVarTuple: Got an unexpected keyword argument 'bound' [incompatible_call]
1515
./generics_typevartuple_basic.py:91:0: Cannot resolve type variables [incompatible_call]

conformance/results/pyrefly/generics_typevartuple_basic.toml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ conformance_automated = "Pass"
33
errors_diff = """
44
"""
55
output = """
6-
ERROR generics_typevartuple_basic.py:42:34-43: Argument `Height` is not assignable to parameter `shape` with type `tuple[*@_]` in function `Array.__init__` [bad-argument-type]
7-
ERROR generics_typevartuple_basic.py:43:35-62: `Array[Batch, Width]` is not assignable to `Array[Batch, Height, Width]` [bad-assignment]
8-
ERROR generics_typevartuple_basic.py:44:41-46:2: `Array[Time, Batch, Width, Height]` is not assignable to `Array[Time, Batch, Height, Width]` [bad-assignment]
9-
ERROR generics_typevartuple_basic.py:52:22-27: `TypeVarTuple` must be unpacked [invalid-annotation]
10-
ERROR generics_typevartuple_basic.py:53:37-42: `TypeVarTuple` must be unpacked [invalid-type-var-tuple]
11-
ERROR generics_typevartuple_basic.py:56:34-39: `TypeVarTuple` must be unpacked [invalid-type-var-tuple]
12-
ERROR generics_typevartuple_basic.py:59:24-29: `TypeVarTuple` must be unpacked [invalid-annotation]
13-
ERROR generics_typevartuple_basic.py:65:27-30: Unexpected positional argument to TypeVarTuple [invalid-type-var-tuple]
14-
ERROR generics_typevartuple_basic.py:66:27-36: Unexpected keyword argument `bound` to TypeVarTuple [invalid-type-var-tuple]
15-
ERROR generics_typevartuple_basic.py:90:15-19: Argument `tuple[Literal[0]]` is not assignable to parameter `arg2` with type `tuple[int, int]` in function `func2` [bad-argument-type]
16-
ERROR generics_typevartuple_basic.py:99:17-18: Argument `Array[Width]` is not assignable to parameter `y` with type `Array[Height]` in function `multiply` [bad-argument-type]
17-
ERROR generics_typevartuple_basic.py:100:17-18: Argument `Array[Height, Width]` is not assignable to parameter `y` with type `Array[Height]` in function `multiply` [bad-argument-type]
18-
ERROR generics_typevartuple_basic.py:106:7-13: Type parameters for class may not have more than one TypeVarTuple [invalid-type-var-tuple]
6+
ERROR generics_typevartuple_basic.py:43:34-43: Argument `Height` is not assignable to parameter `shape` with type `tuple[*@_]` in function `Array.__init__` [bad-argument-type]
7+
ERROR generics_typevartuple_basic.py:44:35-62: `Array[Batch, Width]` is not assignable to `Array[Batch, Height, Width]` [bad-assignment]
8+
ERROR generics_typevartuple_basic.py:45:41-47:2: `Array[Time, Batch, Width, Height]` is not assignable to `Array[Time, Batch, Height, Width]` [bad-assignment]
9+
ERROR generics_typevartuple_basic.py:53:22-27: `TypeVarTuple` must be unpacked [invalid-annotation]
10+
ERROR generics_typevartuple_basic.py:54:37-42: `TypeVarTuple` must be unpacked [invalid-type-var-tuple]
11+
ERROR generics_typevartuple_basic.py:57:34-39: `TypeVarTuple` must be unpacked [invalid-type-var-tuple]
12+
ERROR generics_typevartuple_basic.py:60:24-29: `TypeVarTuple` must be unpacked [invalid-annotation]
13+
ERROR generics_typevartuple_basic.py:66:27-30: Unexpected positional argument to TypeVarTuple [invalid-type-var-tuple]
14+
ERROR generics_typevartuple_basic.py:67:27-36: Unexpected keyword argument `bound` to TypeVarTuple [invalid-type-var-tuple]
15+
ERROR generics_typevartuple_basic.py:91:15-19: Argument `tuple[Literal[0]]` is not assignable to parameter `arg2` with type `tuple[int, int]` in function `func2` [bad-argument-type]
16+
ERROR generics_typevartuple_basic.py:100:17-18: Argument `Array[Width]` is not assignable to parameter `y` with type `Array[Height]` in function `multiply` [bad-argument-type]
17+
ERROR generics_typevartuple_basic.py:101:17-18: Argument `Array[Height, Width]` is not assignable to parameter `y` with type `Array[Height]` in function `multiply` [bad-argument-type]
18+
ERROR generics_typevartuple_basic.py:107:7-13: Type parameters for class may not have more than one TypeVarTuple [invalid-type-var-tuple]
19+
ERROR generics_typevartuple_basic.py:111:7-13: Type parameters for class may not have more than one TypeVarTuple [invalid-type-var-tuple]
1920
"""

0 commit comments

Comments
 (0)