Skip to content

Commit efdb646

Browse files
committed
Conformance suite: rewrite several tests regarding type-parameter defaults to not assume that type checkers will infer a class object as having a type[] type
1 parent 5b5f2f8 commit efdb646

File tree

7 files changed

+129
-93
lines changed

7 files changed

+129
-93
lines changed
Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,20 @@
11
conformant = "Partial"
22
output = """
33
generics_defaults.py:24: error: "T" cannot appear after "DefaultStrT" in type parameter list because it has no default type [misc]
4-
generics_defaults.py:30: error: Expression is of type "type[NoNonDefaults[DefaultStrT, DefaultIntT]]", not "type[NoNonDefaults[str, int]]" [assert-type]
5-
generics_defaults.py:31: error: Expression is of type "type[NoNonDefaults[str, DefaultIntT]]", not "type[NoNonDefaults[str, int]]" [assert-type]
6-
generics_defaults.py:38: error: Expression is of type "type[OneDefault[float, DefaultBoolT]]", not "type[OneDefault[float, bool]]" [assert-type]
7-
generics_defaults.py:45: error: Expression is of type "type[AllTheDefaults[T1, T2, DefaultStrT, DefaultIntT, DefaultBoolT]]", not "type[AllTheDefaults[Any, Any, str, int, bool]]" [assert-type]
8-
generics_defaults.py:46: error: Expression is of type "type[AllTheDefaults[int, complex, DefaultStrT, DefaultIntT, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]
9-
generics_defaults.py:50: error: Type application has too few types (expected between 2 and 5) [misc]
10-
generics_defaults.py:52: error: Expression is of type "type[AllTheDefaults[int, complex, DefaultStrT, DefaultIntT, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]
11-
generics_defaults.py:55: error: Expression is of type "type[AllTheDefaults[int, complex, str, DefaultIntT, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]
12-
generics_defaults.py:59: error: Expression is of type "type[AllTheDefaults[int, complex, str, int, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]
13-
generics_defaults.py:79: error: Expression is of type "type[Class_ParamSpec[DefaultP]]", not "type[Class_ParamSpec[[str, int]]]" [assert-type]
14-
generics_defaults.py:94: error: Expression is of type "type[Class_TypeVarTuple[*DefaultTs]]", not "type[Class_TypeVarTuple[str, int]]" [assert-type]
15-
generics_defaults.py:107: error: TypeVar default must be a subtype of the bound type [misc]
16-
generics_defaults.py:114: error: TypeVar default must be one of the constraint types [misc]
17-
generics_defaults.py:132: error: Expression is of type "int", not "Any" [assert-type]
18-
generics_defaults.py:156: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [float, bool]]]" [assert-type]
19-
generics_defaults.py:156: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]
20-
generics_defaults.py:157: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [bytes]]]" [assert-type]
21-
generics_defaults.py:157: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]
4+
generics_defaults.py:66: error: "AllTheDefaults" expects between 2 and 5 type arguments, but 1 given [type-arg]
5+
generics_defaults.py:139: error: Expression is of type "tuple[*tuple[str, int], ...]", not "tuple[str, int]" [assert-type]
6+
generics_defaults.py:152: error: TypeVar default must be a subtype of the bound type [misc]
7+
generics_defaults.py:159: error: TypeVar default must be one of the constraint types [misc]
8+
generics_defaults.py:177: error: Expression is of type "int", not "Any" [assert-type]
9+
generics_defaults.py:203: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [valid-type]
10+
generics_defaults.py:204: error: Expression is of type "tuple[Any, ...]", not "tuple[int, str]" [assert-type]
11+
generics_defaults.py:205: error: Expression is of type "def (*Any, **Any) -> None", not "Callable[[float, bool], None]" [assert-type]
2212
"""
2313
conformance_automated = "Fail"
2414
errors_diff = """
25-
Line 143: Expected 1 errors
26-
Line 30: Unexpected errors ['generics_defaults.py:30: error: Expression is of type "type[NoNonDefaults[DefaultStrT, DefaultIntT]]", not "type[NoNonDefaults[str, int]]" [assert-type]']
27-
Line 31: Unexpected errors ['generics_defaults.py:31: error: Expression is of type "type[NoNonDefaults[str, DefaultIntT]]", not "type[NoNonDefaults[str, int]]" [assert-type]']
28-
Line 38: Unexpected errors ['generics_defaults.py:38: error: Expression is of type "type[OneDefault[float, DefaultBoolT]]", not "type[OneDefault[float, bool]]" [assert-type]']
29-
Line 45: Unexpected errors ['generics_defaults.py:45: error: Expression is of type "type[AllTheDefaults[T1, T2, DefaultStrT, DefaultIntT, DefaultBoolT]]", not "type[AllTheDefaults[Any, Any, str, int, bool]]" [assert-type]']
30-
Line 46: Unexpected errors ['generics_defaults.py:46: error: Expression is of type "type[AllTheDefaults[int, complex, DefaultStrT, DefaultIntT, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]']
31-
Line 52: Unexpected errors ['generics_defaults.py:52: error: Expression is of type "type[AllTheDefaults[int, complex, DefaultStrT, DefaultIntT, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]']
32-
Line 55: Unexpected errors ['generics_defaults.py:55: error: Expression is of type "type[AllTheDefaults[int, complex, str, DefaultIntT, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]']
33-
Line 59: Unexpected errors ['generics_defaults.py:59: error: Expression is of type "type[AllTheDefaults[int, complex, str, int, DefaultBoolT]]", not "type[AllTheDefaults[int, complex, str, int, bool]]" [assert-type]']
34-
Line 79: Unexpected errors ['generics_defaults.py:79: error: Expression is of type "type[Class_ParamSpec[DefaultP]]", not "type[Class_ParamSpec[[str, int]]]" [assert-type]']
35-
Line 94: Unexpected errors ['generics_defaults.py:94: error: Expression is of type "type[Class_TypeVarTuple[*DefaultTs]]", not "type[Class_TypeVarTuple[str, int]]" [assert-type]']
36-
Line 156: Unexpected errors ['generics_defaults.py:156: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [float, bool]]]" [assert-type]', 'generics_defaults.py:156: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]']
37-
Line 157: Unexpected errors ['generics_defaults.py:157: error: Expression is of type "type[Foo6[*tuple[Any, ...], Any]]", not "type[Foo6[int, str, [bytes]]]" [assert-type]', 'generics_defaults.py:157: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [misc]']
15+
Line 188: Expected 1 errors
16+
Line 139: Unexpected errors ['generics_defaults.py:139: error: Expression is of type "tuple[*tuple[str, int], ...]", not "tuple[str, int]" [assert-type]']
17+
Line 203: Unexpected errors ['generics_defaults.py:203: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "str" [valid-type]']
18+
Line 204: Unexpected errors ['generics_defaults.py:204: error: Expression is of type "tuple[Any, ...]", not "tuple[int, str]" [assert-type]']
19+
Line 205: Unexpected errors ['generics_defaults.py:205: error: Expression is of type "def (*Any, **Any) -> None", not "Callable[[float, bool], None]" [assert-type]']
3820
"""

conformance/results/mypy/generics_defaults_referential.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ generics_defaults_referential.py:53: error: Type parameter "Start2T" has a defau
66
generics_defaults_referential.py:74: error: TypeVar default must be one of the constraint types [misc]
77
generics_defaults_referential.py:77: error: TypeVar default must be one of the constraint types [misc]
88
generics_defaults_referential.py:78: error: TypeVar default must be one of the constraint types [misc]
9-
generics_defaults_referential.py:94: error: Expression is of type "type[Bar[Z1, ListDefaultT]]", not "type[Bar[Any, list[Any]]]" [assert-type]
10-
generics_defaults_referential.py:95: error: Expression is of type "type[Bar[int, ListDefaultT]]", not "type[Bar[int, list[int]]]" [assert-type]
11-
generics_defaults_referential.py:96: error: Expression is of type "Bar[int, list[Never]]", not "Bar[int, list[int]]" [assert-type]
9+
generics_defaults_referential.py:103: error: Expression is of type "Bar[int, list[Never]]", not "Bar[int, list[int]]" [assert-type]
1210
"""
1311
conformance_automated = "Fail"
1412
errors_diff = """
@@ -17,7 +15,5 @@ Line 60: Expected 1 errors
1715
Line 68: Expected 1 errors
1816
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]']
1917
Line 77: Unexpected errors ['generics_defaults_referential.py:77: error: TypeVar default must be one of the constraint types [misc]']
20-
Line 94: Unexpected errors ['generics_defaults_referential.py:94: error: Expression is of type "type[Bar[Z1, ListDefaultT]]", not "type[Bar[Any, list[Any]]]" [assert-type]']
21-
Line 95: Unexpected errors ['generics_defaults_referential.py:95: error: Expression is of type "type[Bar[int, ListDefaultT]]", not "type[Bar[int, list[int]]]" [assert-type]']
22-
Line 96: Unexpected errors ['generics_defaults_referential.py:96: error: Expression is of type "Bar[int, list[Never]]", not "Bar[int, list[int]]" [assert-type]']
18+
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]']
2319
"""

conformance/results/pyrefly/generics_defaults.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ errors_diff = """
33
"""
44
output = """
55
ERROR generics_defaults.py:24:7-31: Type parameter `T` without a default cannot follow type parameter `DefaultStrT` with a default [invalid-type-var]
6-
ERROR generics_defaults.py:50:1-20: Expected 5 type arguments for `AllTheDefaults`, got 1 [bad-specialization]
7-
ERROR generics_defaults.py:107:51-54: Expected default `int` of `Invalid1` to be assignable to the upper bound of `str` [invalid-type-var]
8-
ERROR generics_defaults.py:114:52-55: Expected default `int` of `Invalid2` to be one of the following constraints: `float`, `str` [invalid-type-var]
9-
ERROR generics_defaults.py:132:12-27: assert_type(int, Any) failed [assert-type]
10-
ERROR generics_defaults.py:143:7-11: TypeVar `T5` with a default cannot follow TypeVarTuple `Ts` [invalid-type-var]
6+
ERROR generics_defaults.py:66:8-27: Expected 5 type arguments for `AllTheDefaults`, got 1 [bad-specialization]
7+
ERROR generics_defaults.py:152:51-54: Expected default `int` of `Invalid1` to be assignable to the upper bound of `str` [invalid-type-var]
8+
ERROR generics_defaults.py:159:52-55: Expected default `int` of `Invalid2` to be one of the following constraints: `float`, `str` [invalid-type-var]
9+
ERROR generics_defaults.py:177:12-27: assert_type(int, Any) failed [assert-type]
10+
ERROR generics_defaults.py:188:7-11: TypeVar `T5` with a default cannot follow TypeVarTuple `Ts` [invalid-type-var]
1111
"""

conformance/results/pyright/generics_defaults.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
conformant = "Pass"
22
output = """
33
generics_defaults.py:24:7 - error: "T" cannot appear after "DefaultStrT" in type parameter list because it has no default type (reportGeneralTypeIssues)
4-
generics_defaults.py:50:16 - error: Too few type arguments provided for "AllTheDefaults"; expected 2 but received 1 (reportInvalidTypeArguments)
5-
generics_defaults.py:107:51 - error: TypeVar default type must be a subtype of the bound type (reportGeneralTypeIssues)
6-
generics_defaults.py:114:52 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues)
7-
generics_defaults.py:132:13 - error: "assert_type" mismatch: expected "Any" but received "int" (reportAssertTypeFailure)
8-
generics_defaults.py:143:7 - error: TypeVar "T5" has a default value and cannot follow TypeVarTuple "Ts" (reportGeneralTypeIssues)
4+
generics_defaults.py:66:23 - error: Too few type arguments provided for "AllTheDefaults"; expected 2 but received 1 (reportInvalidTypeArguments)
5+
generics_defaults.py:152:51 - error: TypeVar default type must be a subtype of the bound type (reportGeneralTypeIssues)
6+
generics_defaults.py:159:52 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues)
7+
generics_defaults.py:177:13 - error: "assert_type" mismatch: expected "Any" but received "int" (reportAssertTypeFailure)
8+
generics_defaults.py:188:7 - error: TypeVar "T5" has a default value and cannot follow TypeVarTuple "Ts" (reportGeneralTypeIssues)
99
"""
1010
conformance_automated = "Pass"
1111
errors_diff = """

conformance/results/zuban/generics_defaults.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ errors_diff = """
33
"""
44
output = """
55
generics_defaults.py:24: error: "T" cannot appear after "DefaultStrT" in type parameter list because it has no default type [misc]
6-
generics_defaults.py:50: error: "AllTheDefaults" expects between 2 and 5 type arguments, but 1 given [type-arg]
7-
generics_defaults.py:107: error: TypeVar default must be a subtype of the bound type [misc]
8-
generics_defaults.py:114: error: TypeVar default must be one of the constraint types [misc]
9-
generics_defaults.py:132: error: Expression is of type "int", not "Any" [misc]
10-
generics_defaults.py:143: error: TypeVar defaults are ambiguous after a TypeVarTuple [misc]
6+
generics_defaults.py:66: error: "AllTheDefaults" expects between 2 and 5 type arguments, but 1 given [type-arg]
7+
generics_defaults.py:152: error: TypeVar default must be a subtype of the bound type [misc]
8+
generics_defaults.py:159: error: TypeVar default must be one of the constraint types [misc]
9+
generics_defaults.py:177: error: Expression is of type "int", not "Any" [misc]
10+
generics_defaults.py:188: error: TypeVar defaults are ambiguous after a TypeVarTuple [misc]
1111
"""

conformance/tests/generics_defaults.py

Lines changed: 90 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,46 +24,87 @@
2424
class NonDefaultFollowsDefault(Generic[DefaultStrT, T]): ... # E: non-default TypeVars cannot follow ones with defaults
2525

2626

27-
class NoNonDefaults(Generic[DefaultStrT, DefaultIntT]): ...
27+
class NoNonDefaults(Generic[DefaultStrT, DefaultIntT]):
28+
x: DefaultStrT
29+
y: DefaultIntT
2830

2931

30-
assert_type(NoNonDefaults, type[NoNonDefaults[str, int]])
31-
assert_type(NoNonDefaults[str], type[NoNonDefaults[str, int]])
32-
assert_type(NoNonDefaults[str, int], type[NoNonDefaults[str, int]])
32+
def test_no_non_defaults(a: NoNonDefaults, b: NoNonDefaults[str], c: NoNonDefaults[str, int]):
33+
assert_type(a.x, str)
34+
assert_type(a.y, int)
3335

36+
assert_type(b.x, str)
37+
assert_type(b.y, int)
3438

35-
class OneDefault(Generic[T, DefaultBoolT]): ...
39+
assert_type(c.x, str)
40+
assert_type(c.y, int)
3641

3742

38-
assert_type(OneDefault[float], type[OneDefault[float, bool]])
39-
assert_type(OneDefault[float](), OneDefault[float, bool])
43+
class OneDefault(Generic[T, DefaultBoolT]):
44+
x: T
45+
y: DefaultBoolT
4046

4147

42-
class AllTheDefaults(Generic[T1, T2, DefaultStrT, DefaultIntT, DefaultBoolT]): ...
48+
def test_one_default(a: OneDefault[float], b: OneDefault[float, bool]):
49+
assert_type(a.x, float)
50+
assert_type(a.y, bool)
4351

52+
assert_type(b.x, float)
53+
assert_type(b.y, bool)
4454

45-
assert_type(AllTheDefaults, type[AllTheDefaults[Any, Any, str, int, bool]])
46-
assert_type(
47-
AllTheDefaults[int, complex], type[AllTheDefaults[int, complex, str, int, bool]]
48-
)
4955

50-
AllTheDefaults[int] # E: expected 2 arguments to AllTheDefaults
56+
class AllTheDefaults(Generic[T1, T2, DefaultStrT, DefaultIntT, DefaultBoolT]):
57+
x1: T1
58+
x2: T2
59+
x3: DefaultStrT
60+
x4: DefaultIntT
61+
x5: DefaultBoolT
5162

52-
assert_type(
53-
AllTheDefaults[int, complex], type[AllTheDefaults[int, complex, str, int, bool]]
54-
)
55-
assert_type(
56-
AllTheDefaults[int, complex, str],
57-
type[AllTheDefaults[int, complex, str, int, bool]],
58-
)
59-
assert_type(
60-
AllTheDefaults[int, complex, str, int],
61-
type[AllTheDefaults[int, complex, str, int, bool]],
62-
)
63-
assert_type(
64-
AllTheDefaults[int, complex, str, int, bool],
65-
type[AllTheDefaults[int, complex, str, int, bool]],
66-
)
63+
64+
def test_all_the_defaults(
65+
a: AllTheDefaults,
66+
b: AllTheDefaults[int], # E: expected 2 arguments to AllTheDefaults
67+
c: AllTheDefaults[int, complex],
68+
d: AllTheDefaults[int, complex, str, int, bool],
69+
e: AllTheDefaults[int, complex, str],
70+
f: AllTheDefaults[int, complex, str, int],
71+
g: AllTheDefaults[int, complex, str, int, bool],
72+
):
73+
assert_type(a.x1, Any)
74+
assert_type(a.x2, Any)
75+
assert_type(a.x3, str)
76+
assert_type(a.x4, int)
77+
assert_type(a.x5, bool)
78+
79+
assert_type(c.x1, int)
80+
assert_type(c.x2, complex)
81+
assert_type(c.x3, str)
82+
assert_type(c.x4, int)
83+
assert_type(c.x5, bool)
84+
85+
assert_type(d.x1, int)
86+
assert_type(d.x2, complex)
87+
assert_type(d.x3, str)
88+
assert_type(d.x4, int)
89+
assert_type(d.x5, bool)
90+
91+
assert_type(e.x1, int)
92+
assert_type(e.x2, complex)
93+
assert_type(e.x3, str)
94+
assert_type(e.x4, int)
95+
assert_type(e.x5, bool)
96+
97+
assert_type(f.x1, int)
98+
assert_type(f.x2, complex)
99+
assert_type(f.x3, str)
100+
assert_type(f.x4, int)
101+
assert_type(f.x5, bool)
102+
103+
assert_type(g.x1, int)
104+
assert_type(g.x2, complex)
105+
assert_type(g.x3, str)
106+
assert_type(g.x4, int)
107+
assert_type(g.x5, bool)
67108

68109

69110
# > ``ParamSpec`` defaults are defined using the same syntax as
@@ -73,12 +114,14 @@ class AllTheDefaults(Generic[T1, T2, DefaultStrT, DefaultIntT, DefaultBoolT]): .
73114
DefaultP = ParamSpec("DefaultP", default=[str, int])
74115

75116

76-
class Class_ParamSpec(Generic[DefaultP]): ...
117+
class Class_ParamSpec(Generic[DefaultP]):
118+
x: Callable[DefaultP, None]
77119

78120

79-
assert_type(Class_ParamSpec, type[Class_ParamSpec[str, int]])
80-
assert_type(Class_ParamSpec(), Class_ParamSpec[str, int])
81-
assert_type(Class_ParamSpec[[bool, bool]](), Class_ParamSpec[bool, bool])
121+
def test_param_spec_defaults(a: Class_ParamSpec):
122+
assert_type(a.x, Callable[[str, int], None])
123+
assert_type(Class_ParamSpec(), Class_ParamSpec[str, int])
124+
assert_type(Class_ParamSpec[[bool, bool]](), Class_ParamSpec[bool, bool])
82125

83126

84127
# > ``TypeVarTuple`` defaults are defined using the same syntax as
@@ -88,12 +131,14 @@ class Class_ParamSpec(Generic[DefaultP]): ...
88131
DefaultTs = TypeVarTuple("DefaultTs", default=Unpack[tuple[str, int]])
89132

90133

91-
class Class_TypeVarTuple(Generic[*DefaultTs]): ...
134+
class Class_TypeVarTuple(Generic[*DefaultTs]):
135+
x: tuple[*DefaultTs]
92136

93137

94-
assert_type(Class_TypeVarTuple, type[Class_TypeVarTuple[*tuple[str, int]]])
95-
assert_type(Class_TypeVarTuple(), Class_TypeVarTuple[str, int])
96-
assert_type(Class_TypeVarTuple[int, bool](), Class_TypeVarTuple[int, bool])
138+
def test_type_var_tuple_defaults(a: Class_TypeVarTuple):
139+
assert_type(a.x, tuple[str, int])
140+
assert_type(Class_TypeVarTuple(), Class_TypeVarTuple[str, int])
141+
assert_type(Class_TypeVarTuple[int, bool](), Class_TypeVarTuple[int, bool])
97142

98143

99144
AnotherDefaultTs = TypeVarTuple("AnotherDefaultTs", default=Unpack[DefaultTs])
@@ -150,11 +195,17 @@ class Foo5(Generic[*Ts, T5]): ... # E
150195
P = ParamSpec("P", default=[float, bool])
151196

152197

153-
class Foo6(Generic[*Ts, P]): ... # OK
198+
class Foo6(Generic[*Ts, P]):
199+
x: tuple[*Ts]
200+
y: Callable[P, None]
201+
154202

203+
def test_foo6(a: Foo6[int, str], b: Foo6[int, str, [bytes]]):
204+
assert_type(a.x, tuple[int, str])
205+
assert_type(a.y, Callable[[float, bool], None])
155206

156-
assert_type(Foo6[int, str], type[Foo6[int, str, [float, bool]]])
157-
assert_type(Foo6[int, str, [bytes]], type[Foo6[int, str, [bytes]]])
207+
assert_type(b.x, tuple[int, str])
208+
assert_type(b.y, Callable[[bytes], None])
158209

159210

160211
# > Type parameter defaults should be bound by attribute access

conformance/tests/generics_defaults_referential.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,18 @@ class Bar2(Generic[S2]): ... # E
8888

8989

9090
class Bar(Generic[Z1, ListDefaultT]): # OK
91+
x: Z1
92+
y: ListDefaultT
9193
def __init__(self, x: Z1, y: ListDefaultT): ...
9294

9395

94-
assert_type(Bar, type[Bar[Any, list[Any]]])
95-
assert_type(Bar[int], type[Bar[int, list[int]]])
96+
def f(b1: Bar, b2: Bar[int]):
97+
assert_type(b1.x, Any)
98+
assert_type(b1.y, list[Any])
99+
assert_type(b2.x, int)
100+
assert_type(b2.y, list[int])
101+
102+
96103
assert_type(Bar[int](0, []), Bar[int, list[int]])
97104
assert_type(Bar[int, list[str]](0, []), Bar[int, list[str]])
98105
assert_type(Bar[int, str](0, ""), Bar[int, str])

0 commit comments

Comments
 (0)