@@ -2046,16 +2046,91 @@ def f(x: *b)
20462046 ...
20472047 SyntaxError: Type parameter list cannot be empty
20482048
2049+ >>> def f[T: (x:=3)](): pass
2050+ Traceback (most recent call last):
2051+ ...
2052+ SyntaxError: named expression cannot be used within a TypeVar bound
2053+
2054+ >>> def f[T: ((x:= 3), int)](): pass
2055+ Traceback (most recent call last):
2056+ ...
2057+ SyntaxError: named expression cannot be used within a TypeVar constraint
2058+
2059+ >>> def f[T = ((x:=3))](): pass
2060+ Traceback (most recent call last):
2061+ ...
2062+ SyntaxError: named expression cannot be used within a TypeVar default
2063+
2064+ >>> async def f[T: (x:=3)](): pass
2065+ Traceback (most recent call last):
2066+ ...
2067+ SyntaxError: named expression cannot be used within a TypeVar bound
2068+
2069+ >>> async def f[T: ((x:= 3), int)](): pass
2070+ Traceback (most recent call last):
2071+ ...
2072+ SyntaxError: named expression cannot be used within a TypeVar constraint
2073+
2074+ >>> async def f[T = ((x:=3))](): pass
2075+ Traceback (most recent call last):
2076+ ...
2077+ SyntaxError: named expression cannot be used within a TypeVar default
2078+
20492079 >>> type A[T: (x:=3)] = int
20502080 Traceback (most recent call last):
20512081 ...
20522082 SyntaxError: named expression cannot be used within a TypeVar bound
20532083
2084+ >>> type A[T: ((x:= 3), int)] = int
2085+ Traceback (most recent call last):
2086+ ...
2087+ SyntaxError: named expression cannot be used within a TypeVar constraint
2088+
2089+ >>> type A[T = ((x:=3))] = int
2090+ Traceback (most recent call last):
2091+ ...
2092+ SyntaxError: named expression cannot be used within a TypeVar default
2093+
2094+ >>> def f[T: (yield)](): pass
2095+ Traceback (most recent call last):
2096+ ...
2097+ SyntaxError: yield expression cannot be used within a TypeVar bound
2098+
2099+ >>> def f[T: (int, (yield))](): pass
2100+ Traceback (most recent call last):
2101+ ...
2102+ SyntaxError: yield expression cannot be used within a TypeVar constraint
2103+
2104+ >>> def f[T = (yield)](): pass
2105+ Traceback (most recent call last):
2106+ ...
2107+ SyntaxError: yield expression cannot be used within a TypeVar default
2108+
2109+ >>> def f[*Ts = (yield)](): pass
2110+ Traceback (most recent call last):
2111+ ...
2112+ SyntaxError: yield expression cannot be used within a TypeVarTuple default
2113+
2114+ >>> def f[**P = [(yield), int]](): pass
2115+ Traceback (most recent call last):
2116+ ...
2117+ SyntaxError: yield expression cannot be used within a ParamSpec default
2118+
20542119 >>> type A[T: (yield 3)] = int
20552120 Traceback (most recent call last):
20562121 ...
20572122 SyntaxError: yield expression cannot be used within a TypeVar bound
20582123
2124+ >>> type A[T: (int, (yield 3))] = int
2125+ Traceback (most recent call last):
2126+ ...
2127+ SyntaxError: yield expression cannot be used within a TypeVar constraint
2128+
2129+ >>> type A[T = (yield 3)] = int
2130+ Traceback (most recent call last):
2131+ ...
2132+ SyntaxError: yield expression cannot be used within a TypeVar default
2133+
20592134 >>> type A[T: (await 3)] = int
20602135 Traceback (most recent call last):
20612136 ...
@@ -2066,6 +2141,31 @@ def f(x: *b)
20662141 ...
20672142 SyntaxError: yield expression cannot be used within a TypeVar bound
20682143
2144+ >>> class A[T: (yield 3)]: pass
2145+ Traceback (most recent call last):
2146+ ...
2147+ SyntaxError: yield expression cannot be used within a TypeVar bound
2148+
2149+ >>> class A[T: (int, (yield 3))]: pass
2150+ Traceback (most recent call last):
2151+ ...
2152+ SyntaxError: yield expression cannot be used within a TypeVar constraint
2153+
2154+ >>> class A[T = (yield)]: pass
2155+ Traceback (most recent call last):
2156+ ...
2157+ SyntaxError: yield expression cannot be used within a TypeVar default
2158+
2159+ >>> class A[*Ts = (yield)]: pass
2160+ Traceback (most recent call last):
2161+ ...
2162+ SyntaxError: yield expression cannot be used within a TypeVarTuple default
2163+
2164+ >>> class A[**P = [(yield), int]]: pass
2165+ Traceback (most recent call last):
2166+ ...
2167+ SyntaxError: yield expression cannot be used within a ParamSpec default
2168+
20692169 >>> type A = (x := 3)
20702170 Traceback (most recent call last):
20712171 ...
0 commit comments