Skip to content

Commit dcffbae

Browse files
Remove class-object assertion from defaults test (#2343)
1 parent bee91c2 commit dcffbae

7 files changed

Lines changed: 49 additions & 54 deletions

conformance/results/mypy/generics_defaults_referential.toml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@ notes = """
33
Does not correctly handle defaults referencing other `TypeVar`s.
44
"""
55
output = """
6-
generics_defaults_referential.py:23: error: Expression is of type "type[slice[StartT, StopT, StepT]]", not "type[slice[int, int, int | None]]" [assert-type]
7-
generics_defaults_referential.py:38: error: Argument 1 to "Foo" has incompatible type "str"; expected "int" [arg-type]
8-
generics_defaults_referential.py:54: error: Type parameter "Start2T" has a default type that refers to one or more type variables that are out of scope [misc]
9-
generics_defaults_referential.py:61: error: Type variable S1 referenced in the default of S2 is unbound [misc]
10-
generics_defaults_referential.py:75: error: TypeVar default must be one of the constraint types [misc]
6+
generics_defaults_referential.py:37: error: Argument 1 to "Foo" has incompatible type "str"; expected "int" [arg-type]
7+
generics_defaults_referential.py:53: error: Type parameter "Start2T" has a default type that refers to one or more type variables that are out of scope [misc]
8+
generics_defaults_referential.py:60: error: Type variable S1 referenced in the default of S2 is unbound [misc]
9+
generics_defaults_referential.py:74: error: TypeVar default must be one of the constraint types [misc]
10+
generics_defaults_referential.py:77: error: TypeVar default must be one of the constraint types [misc]
1111
generics_defaults_referential.py:78: error: TypeVar default must be one of the constraint types [misc]
12-
generics_defaults_referential.py:79: error: TypeVar default must be one of the constraint types [misc]
13-
generics_defaults_referential.py:104: error: Expression is of type "Bar[int, list[Never]]", not "Bar[int, list[int]]" [assert-type]
12+
generics_defaults_referential.py:103: error: Expression is of type "Bar[int, list[Never]]", not "Bar[int, list[int]]" [assert-type]
1413
"""
1514
conformance_automated = "Fail"
1615
errors_diff = """
17-
Line 37: Expected 1 errors
18-
Line 69: Expected 1 errors
19-
Line 23: Unexpected errors ['generics_defaults_referential.py:23: error: Expression is of type "type[slice[StartT, StopT, StepT]]", not "type[slice[int, int, int | None]]" [assert-type]']
20-
Line 78: Unexpected errors ['generics_defaults_referential.py:78: error: TypeVar default must be one of the constraint types [misc]']
21-
Line 104: Unexpected errors ['generics_defaults_referential.py:104: error: Expression is of type "Bar[int, list[Never]]", not "Bar[int, list[int]]" [assert-type]']
16+
Line 36: Expected 1 errors
17+
Line 68: Expected 1 errors
18+
Line 77: Unexpected errors ['generics_defaults_referential.py:77: error: TypeVar default must be one of the constraint types [misc]']
19+
Line 103: Unexpected errors ['generics_defaults_referential.py:103: error: Expression is of type "Bar[int, list[Never]]", not "Bar[int, list[int]]" [assert-type]']
2220
"""

conformance/results/pycroscope/generics_defaults_referential.toml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,17 @@ Fails to apply default specializations in some cases.
44
"""
55
conformance_automated = "Fail"
66
errors_diff = """
7-
Line 23: Unexpected errors ["./generics_defaults_referential.py:23:12: type 'generics_defaults_referential.slice' is not equivalent to type[generics_defaults_referential.slice[int, int, int | None]]"]
8-
Line 98: Unexpected errors ['./generics_defaults_referential.py:98:16: ~Z1@generics_defaults_referential.Bar is not equivalent to Any[explicit]']
9-
Line 99: Unexpected errors ['./generics_defaults_referential.py:99:16: ~ListDefaultT@generics_defaults_referential.Bar is not equivalent to list[Any[explicit]]']
7+
Line 97: Unexpected errors ['./generics_defaults_referential.py:97:16: ~Z1@generics_defaults_referential.Bar is not equivalent to Any[explicit]']
8+
Line 98: Unexpected errors ['./generics_defaults_referential.py:98:16: ~ListDefaultT@generics_defaults_referential.Bar is not equivalent to list[Any[explicit]]']
109
"""
1110
output = """
12-
./generics_defaults_referential.py:23:12: type 'generics_defaults_referential.slice' is not equivalent to type[generics_defaults_referential.slice[int, int, int | None]]
13-
./generics_defaults_referential.py:37:16: Incompatible argument type for b: expected int but got str [incompatible_argument]
14-
./generics_defaults_referential.py:38:13: Incompatible argument type for a: expected int but got str [incompatible_argument]
15-
./generics_defaults_referential.py:54:0: Type parameter defaults can reference only earlier type parameters from the same class [invalid_type_parameter]
16-
./generics_defaults_referential.py:61:4: Type parameter defaults can reference only earlier type parameters from the same class [invalid_type_parameter]
17-
./generics_defaults_referential.py:69:39: TypeVar default must be assignable to its bound [incompatible_call]
18-
./generics_defaults_referential.py:75:51: TypeVar default must be one of its constraints [incompatible_call]
19-
./generics_defaults_referential.py:79:62: TypeVar default must be one of its constraints [incompatible_call]
20-
./generics_defaults_referential.py:98:16: ~Z1@generics_defaults_referential.Bar is not equivalent to Any[explicit]
21-
./generics_defaults_referential.py:99:16: ~ListDefaultT@generics_defaults_referential.Bar is not equivalent to list[Any[explicit]]
11+
./generics_defaults_referential.py:36:16: Incompatible argument type for b: expected int but got str [incompatible_argument]
12+
./generics_defaults_referential.py:37:13: Incompatible argument type for a: expected int but got str [incompatible_argument]
13+
./generics_defaults_referential.py:53:0: Type parameter defaults can reference only earlier type parameters from the same class [invalid_type_parameter]
14+
./generics_defaults_referential.py:60:4: Type parameter defaults can reference only earlier type parameters from the same class [invalid_type_parameter]
15+
./generics_defaults_referential.py:68:39: TypeVar default must be assignable to its bound [incompatible_call]
16+
./generics_defaults_referential.py:74:51: TypeVar default must be one of its constraints [incompatible_call]
17+
./generics_defaults_referential.py:78:62: TypeVar default must be one of its constraints [incompatible_call]
18+
./generics_defaults_referential.py:97:16: ~Z1@generics_defaults_referential.Bar is not equivalent to Any[explicit]
19+
./generics_defaults_referential.py:98:16: ~ListDefaultT@generics_defaults_referential.Bar is not equivalent to list[Any[explicit]]
2220
"""

conformance/results/pyrefly/generics_defaults_referential.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ conformance_automated = "Pass"
33
errors_diff = """
44
"""
55
output = """
6-
ERROR generics_defaults_referential.py:37:17-18: Argument `str` is not assignable to parameter `b` with type `int` in function `Foo.__init__` [bad-argument-type]
7-
ERROR generics_defaults_referential.py:38:14-15: Argument `str` is not assignable to parameter `a` with type `int` in function `Foo.__init__` [bad-argument-type]
8-
ERROR generics_defaults_referential.py:54:7-13: Default of type parameter `Start2T` refers to out-of-scope type parameter `StopT` [invalid-type-var]
9-
ERROR generics_defaults_referential.py:61:11-15: Default of type parameter `S2` refers to out-of-scope type parameter `S1` [invalid-type-var]
10-
ERROR generics_defaults_referential.py:69:40-42: Expected default `TypeVar[X1]` of `Invalid1` to be assignable to the upper bound of `str` [invalid-type-var]
11-
ERROR generics_defaults_referential.py:75:52-54: Expected default `TypeVar[Y1]` of `Invalid2` to be one of the following constraints: `float`, `str` [invalid-type-var]
12-
ERROR generics_defaults_referential.py:79:63-65: Expected default `TypeVar[Y2]` of `AlsoInvalid2` to be one of the following constraints: `bool`, `complex` [invalid-type-var]
6+
ERROR generics_defaults_referential.py:36:17-18: Argument `str` is not assignable to parameter `b` with type `int` in function `Foo.__init__` [bad-argument-type]
7+
ERROR generics_defaults_referential.py:37:14-15: Argument `str` is not assignable to parameter `a` with type `int` in function `Foo.__init__` [bad-argument-type]
8+
ERROR generics_defaults_referential.py:53:7-13: Default of type parameter `Start2T` refers to out-of-scope type parameter `StopT` [invalid-type-var]
9+
ERROR generics_defaults_referential.py:60:11-15: Default of type parameter `S2` refers to out-of-scope type parameter `S1` [invalid-type-var]
10+
ERROR generics_defaults_referential.py:68:40-42: Expected default `TypeVar[X1]` of `Invalid1` to be assignable to the upper bound of `str` [invalid-type-var]
11+
ERROR generics_defaults_referential.py:74:52-54: Expected default `TypeVar[Y1]` of `Invalid2` to be one of the following constraints: `float`, `str` [invalid-type-var]
12+
ERROR generics_defaults_referential.py:78:63-65: Expected default `TypeVar[Y2]` of `AlsoInvalid2` to be one of the following constraints: `bool`, `complex` [invalid-type-var]
1313
"""

conformance/results/pyright/generics_defaults_referential.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
conformant = "Pass"
22
output = """
3-
generics_defaults_referential.py:37:17 - error: Argument of type "str" cannot be assigned to parameter "b" of type "int" in function "__init__"
3+
generics_defaults_referential.py:36:17 - error: Argument of type "str" cannot be assigned to parameter "b" of type "int" in function "__init__"
44
  "str" is not assignable to "int" (reportArgumentType)
5-
generics_defaults_referential.py:38:14 - error: Argument of type "str" cannot be assigned to parameter "a" of type "int" in function "__init__"
5+
generics_defaults_referential.py:37:14 - error: Argument of type "str" cannot be assigned to parameter "a" of type "int" in function "__init__"
66
  "str" is not assignable to "int" (reportArgumentType)
7-
generics_defaults_referential.py:54:7 - error: Type parameter "Start2T" has a default type that refers to one or more type variables that are out of scope
7+
generics_defaults_referential.py:53:7 - error: Type parameter "Start2T" has a default type that refers to one or more type variables that are out of scope
88
  Type variable "StopT" is not in scope (reportGeneralTypeIssues)
9-
generics_defaults_referential.py:61:11 - error: Type parameter "S2" has a default type that refers to one or more type variables that are out of scope
9+
generics_defaults_referential.py:60:11 - error: Type parameter "S2" has a default type that refers to one or more type variables that are out of scope
1010
  Type variable "S1" is not in scope (reportGeneralTypeIssues)
11-
generics_defaults_referential.py:69:40 - error: TypeVar default type must be a subtype of the bound type (reportGeneralTypeIssues)
12-
generics_defaults_referential.py:75:52 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues)
13-
generics_defaults_referential.py:79:63 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues)
11+
generics_defaults_referential.py:68:40 - error: TypeVar default type must be a subtype of the bound type (reportGeneralTypeIssues)
12+
generics_defaults_referential.py:74:52 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues)
13+
generics_defaults_referential.py:78:63 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues)
1414
"""
1515
conformance_automated = "Pass"
1616
errors_diff = """

conformance/results/ty/generics_defaults_referential.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ conformance_automated = "Pass"
22
errors_diff = """
33
"""
44
output = """
5-
generics_defaults_referential.py:37:17: error[invalid-argument-type] Argument to `Foo.__init__` is incorrect: Expected `int`, found `str`
6-
generics_defaults_referential.py:38:14: error[invalid-argument-type] Argument to `Foo.__init__` is incorrect: Expected `int`, found `str`
7-
generics_defaults_referential.py:54:7: error[invalid-generic-class] Default of `Start2T` cannot reference out-of-scope type variable `StopT`
8-
generics_defaults_referential.py:61:11: error[invalid-generic-class] Default of `S2` cannot reference out-of-scope type variable `S1`
9-
generics_defaults_referential.py:69:40: error[invalid-type-variable-default] Default `X1` of TypeVar `Invalid1` is not assignable to upper bound `str` of `Invalid1` because its upper bound `int` is not assignable to `str`
10-
generics_defaults_referential.py:75:52: error[invalid-type-variable-default] TypeVar default is inconsistent with the TypeVar's constraints: Bounded TypeVar cannot be used as the default for a constrained TypeVar
11-
generics_defaults_referential.py:79:63: error[invalid-type-variable-default] Default `Y2` of TypeVar `AlsoInvalid2` is inconsistent with its constraints `AlsoInvalid2` because constraint `int` of `Y2` is not one of the constraints of `AlsoInvalid2`
5+
generics_defaults_referential.py:36:17: error[invalid-argument-type] Argument to `Foo.__init__` is incorrect: Expected `int`, found `str`
6+
generics_defaults_referential.py:37:14: error[invalid-argument-type] Argument to `Foo.__init__` is incorrect: Expected `int`, found `str`
7+
generics_defaults_referential.py:53:7: error[invalid-generic-class] Default of `Start2T` cannot reference out-of-scope type variable `StopT`
8+
generics_defaults_referential.py:60:11: error[invalid-generic-class] Default of `S2` cannot reference out-of-scope type variable `S1`
9+
generics_defaults_referential.py:68:40: error[invalid-type-variable-default] Default `X1` of TypeVar `Invalid1` is not assignable to upper bound `str` of `Invalid1` because its upper bound `int` is not assignable to `str`
10+
generics_defaults_referential.py:74:52: error[invalid-type-variable-default] TypeVar default is inconsistent with the TypeVar's constraints: Bounded TypeVar cannot be used as the default for a constrained TypeVar
11+
generics_defaults_referential.py:78:63: error[invalid-type-variable-default] Default `Y2` of TypeVar `AlsoInvalid2` is inconsistent with its constraints `AlsoInvalid2` because constraint `int` of `Y2` is not one of the constraints of `AlsoInvalid2`
1212
"""

conformance/results/zuban/generics_defaults_referential.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ conformance_automated = "Pass"
22
errors_diff = """
33
"""
44
output = """
5-
generics_defaults_referential.py:37: error: Argument 2 to "Foo" has incompatible type "str"; expected "int" [arg-type]
6-
generics_defaults_referential.py:38: error: Argument 1 to "Foo" has incompatible type "str"; expected "int" [arg-type]
7-
generics_defaults_referential.py:54: error: Type parameter "Start2T" has a default type that refers to one or more type variables that are out of scope [misc]
8-
generics_defaults_referential.py:61: error: Type parameter "S2" has a default type that refers to one or more type variables that are out of scope [misc]
9-
generics_defaults_referential.py:69: error: TypeVar default must be a subtype of the bound type [misc]
10-
generics_defaults_referential.py:75: error: TypeVar default must be one of the constraint types [misc]
11-
generics_defaults_referential.py:79: error: TypeVar default must be one of the constraint types [misc]
5+
generics_defaults_referential.py:36: error: Argument 2 to "Foo" has incompatible type "str"; expected "int" [arg-type]
6+
generics_defaults_referential.py:37: error: Argument 1 to "Foo" has incompatible type "str"; expected "int" [arg-type]
7+
generics_defaults_referential.py:53: error: Type parameter "Start2T" has a default type that refers to one or more type variables that are out of scope [misc]
8+
generics_defaults_referential.py:60: error: Type parameter "S2" has a default type that refers to one or more type variables that are out of scope [misc]
9+
generics_defaults_referential.py:68: error: TypeVar default must be a subtype of the bound type [misc]
10+
generics_defaults_referential.py:74: error: TypeVar default must be one of the constraint types [misc]
11+
generics_defaults_referential.py:78: error: TypeVar default must be one of the constraint types [misc]
1212
"""

conformance/tests/generics_defaults_referential.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
class slice(Generic[StartT, StopT, StepT]): ...
2121

2222

23-
assert_type(slice, type[slice[int, int, int | None]])
2423
assert_type(slice(), slice[int, int, int | None])
2524
assert_type(slice[str](), slice[str, str, int | None])
2625
assert_type(slice[str, bool, complex](), slice[str, bool, complex])

0 commit comments

Comments
 (0)