@@ -1877,6 +1877,68 @@ def f(x: *b)
1877
1877
^^^^^^^^^^^
1878
1878
SyntaxError: bytes can only contain ASCII literal characters
1879
1879
1880
+ Invalid expressions in type scopes:
1881
+
1882
+ >>> type A[T: (x:=3)] = int
1883
+ Traceback (most recent call last):
1884
+ ...
1885
+ SyntaxError: named expression cannot be used within a TypeVar bound
1886
+
1887
+ >>> type A[T: (yield 3)] = int
1888
+ Traceback (most recent call last):
1889
+ ...
1890
+ SyntaxError: yield expression cannot be used within a TypeVar bound
1891
+
1892
+ >>> type A[T: (await 3)] = int
1893
+ Traceback (most recent call last):
1894
+ ...
1895
+ SyntaxError: await expression cannot be used within a TypeVar bound
1896
+
1897
+ >>> type A[T: (yield from [])] = int
1898
+ Traceback (most recent call last):
1899
+ ...
1900
+ SyntaxError: yield expression cannot be used within a TypeVar bound
1901
+
1902
+ >>> type A = (x := 3)
1903
+ Traceback (most recent call last):
1904
+ ...
1905
+ SyntaxError: named expression cannot be used within a type alias
1906
+
1907
+ >>> type A = (yield 3)
1908
+ Traceback (most recent call last):
1909
+ ...
1910
+ SyntaxError: yield expression cannot be used within a type alias
1911
+
1912
+ >>> type A = (await 3)
1913
+ Traceback (most recent call last):
1914
+ ...
1915
+ SyntaxError: await expression cannot be used within a type alias
1916
+
1917
+ >>> type A = (yield from [])
1918
+ Traceback (most recent call last):
1919
+ ...
1920
+ SyntaxError: yield expression cannot be used within a type alias
1921
+
1922
+ >>> class A[T]((x := 3)): ...
1923
+ Traceback (most recent call last):
1924
+ ...
1925
+ SyntaxError: named expression cannot be used within the definition of a generic
1926
+
1927
+ >>> class A[T]((yield 3)): ...
1928
+ Traceback (most recent call last):
1929
+ ...
1930
+ SyntaxError: yield expression cannot be used within the definition of a generic
1931
+
1932
+ >>> class A[T]((await 3)): ...
1933
+ Traceback (most recent call last):
1934
+ ...
1935
+ SyntaxError: await expression cannot be used within the definition of a generic
1936
+
1937
+ >>> class A[T]((yield from [])): ...
1938
+ Traceback (most recent call last):
1939
+ ...
1940
+ SyntaxError: yield expression cannot be used within the definition of a generic
1941
+
1880
1942
"""
1881
1943
1882
1944
import re
0 commit comments