Skip to content

Commit b001edf

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

4 files changed

Lines changed: 62 additions & 4 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
conformant = "Fail"
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+
"""

conformance/results/pycroscope/generics_typevartuple_basic.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
conformant = "Fail"
12
conformance_automated = "Fail"
23
errors_diff = """
34
Line 111: Expected 1 errors
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
conformant = "Fail"
2+
conformance_automated = "Fail"
3+
errors_diff = """
4+
Line 16: Expected 1 errors
5+
Line 36: 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:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.ContravariantTypeVarTuple[int], got ./generics_typevartuple_variance.py.ContravariantTypeVarTuple[object] [incompatible_assignment]']
9+
Line 33: Unexpected errors ['./generics_typevartuple_variance.py:33:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.CovariantTypeVarTuple[object], got ./generics_typevartuple_variance.py.CovariantTypeVarTuple[int] [incompatible_assignment]']
10+
Line 34: Unexpected errors ['./generics_typevartuple_variance.py:34:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.CovariantTypeVarTuple[float | int, float | int], got ./generics_typevartuple_variance.py.CovariantTypeVarTuple[int, object] [incompatible_assignment]']
11+
Line 54: Unexpected errors ["./generics_typevartuple_variance.py:54:7: Error calling (name: str, /, *, default: TypeForm[object] = <no argument given>, bound: TypeForm[object] = <no argument given>, covariant: bool = Literal[False], contravariant: bool = Literal[False], infer_variance: bool = Literal[False]) -> typing_extensions.TypeVarTuple (with impl): TypeVarTuple.__new__() got an unexpected keyword argument 'contravariant' [incompatible_call]"]
12+
Line 65: Unexpected errors ['./generics_typevartuple_variance.py:65:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.ContravariantTypeVarTupleOld[int], got ./generics_typevartuple_variance.py.ContravariantTypeVarTupleOld[object] [incompatible_assignment]']
13+
Line 68: Unexpected errors ["./generics_typevartuple_variance.py:68:8: Error calling (name: str, /, *, default: TypeForm[object] = <no argument given>, bound: TypeForm[object] = <no argument given>, covariant: bool = Literal[False], contravariant: bool = Literal[False], infer_variance: bool = Literal[False]) -> typing_extensions.TypeVarTuple (with impl): TypeVarTuple.__new__() got an unexpected keyword argument 'covariant' [incompatible_call]"]
14+
Line 79: Unexpected errors ['./generics_typevartuple_variance.py:79:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.CovariantTypeVarTupleOld[object], got ./generics_typevartuple_variance.py.CovariantTypeVarTupleOld[int] [incompatible_assignment]']
15+
"""
16+
output = """
17+
./generics_typevartuple_variance.py:14:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.InvariantTypeVarTuple[object], got ./generics_typevartuple_variance.py.InvariantTypeVarTuple[int] [incompatible_assignment]
18+
./generics_typevartuple_variance.py:15:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.InvariantTypeVarTuple[int], got ./generics_typevartuple_variance.py.InvariantTypeVarTuple[object] [incompatible_assignment]
19+
./generics_typevartuple_variance.py:23:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.ContravariantTypeVarTuple[object, object], got ./generics_typevartuple_variance.py.ContravariantTypeVarTuple[int] [incompatible_assignment]
20+
./generics_typevartuple_variance.py:24:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.ContravariantTypeVarTuple[int], got ./generics_typevartuple_variance.py.ContravariantTypeVarTuple[object] [incompatible_assignment]
21+
./generics_typevartuple_variance.py:32:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.CovariantTypeVarTuple[int], got ./generics_typevartuple_variance.py.CovariantTypeVarTuple[object] [incompatible_assignment]
22+
./generics_typevartuple_variance.py:33:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.CovariantTypeVarTuple[object], got ./generics_typevartuple_variance.py.CovariantTypeVarTuple[int] [incompatible_assignment]
23+
./generics_typevartuple_variance.py:34:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.CovariantTypeVarTuple[float | int, float | int], got ./generics_typevartuple_variance.py.CovariantTypeVarTuple[int, object] [incompatible_assignment]
24+
./generics_typevartuple_variance.py:50:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.InvariantTypeVarTupleOld[object], got ./generics_typevartuple_variance.py.InvariantTypeVarTupleOld[int] [incompatible_assignment]
25+
./generics_typevartuple_variance.py:51:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.InvariantTypeVarTupleOld[int], got ./generics_typevartuple_variance.py.InvariantTypeVarTupleOld[object] [incompatible_assignment]
26+
./generics_typevartuple_variance.py:54:7: Error calling (name: str, /, *, default: TypeForm[object] = <no argument given>, bound: TypeForm[object] = <no argument given>, covariant: bool = Literal[False], contravariant: bool = Literal[False], infer_variance: bool = Literal[False]) -> typing_extensions.TypeVarTuple (with impl): TypeVarTuple.__new__() got an unexpected keyword argument 'contravariant' [incompatible_call]
27+
./generics_typevartuple_variance.py:64:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.ContravariantTypeVarTupleOld[object], got ./generics_typevartuple_variance.py.ContravariantTypeVarTupleOld[int] [incompatible_assignment]
28+
./generics_typevartuple_variance.py:65:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.ContravariantTypeVarTupleOld[int], got ./generics_typevartuple_variance.py.ContravariantTypeVarTupleOld[object] [incompatible_assignment]
29+
./generics_typevartuple_variance.py:68:8: Error calling (name: str, /, *, default: TypeForm[object] = <no argument given>, bound: TypeForm[object] = <no argument given>, covariant: bool = Literal[False], contravariant: bool = Literal[False], infer_variance: bool = Literal[False]) -> typing_extensions.TypeVarTuple (with impl): TypeVarTuple.__new__() got an unexpected keyword argument 'covariant' [incompatible_call]
30+
./generics_typevartuple_variance.py:78:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.CovariantTypeVarTupleOld[int], got ./generics_typevartuple_variance.py.CovariantTypeVarTupleOld[object] [incompatible_assignment]
31+
./generics_typevartuple_variance.py:79:0: Incompatible assignment: expected ./generics_typevartuple_variance.py.CovariantTypeVarTupleOld[object], got ./generics_typevartuple_variance.py.CovariantTypeVarTupleOld[int] [incompatible_assignment]
32+
"""

docs/spec/generics.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2724,10 +2724,10 @@ instance (a concrete anonymous class that is assumed to meet the bounds or
27242724
constraints of the type parameter). In the ``upper`` specialized class,
27252725
specialize the target type parameter with:
27262726

2727-
an ``object`` instance for a type variable. a ``*tuple[object, ...]``
2728-
value for a type variable tuple. For a parameter specification,
2729-
a 'top signature' value, i.e. a type that represents the super type of
2730-
every possible signature.
2727+
- an ``object`` instance for a type variable
2728+
- a ``*tuple[object, ...]`` value for a type variable tuple
2729+
- a "top signature" value for a parameter specification, i.e. a type that
2730+
represents the super type of every possible signature.
27312731

27322732
This specialization ignores the type parameter's upper bound or constraints.
27332733
In the ``lower`` specialized class, specialize the target type parameter with

0 commit comments

Comments
 (0)