@@ -144,6 +144,11 @@ def ast3_parse(
144
144
NamedExpr = ast3 .NamedExpr
145
145
Constant = ast3 .Constant
146
146
147
+ if sys .version_info >= (3 , 12 ):
148
+ ast_TypeAlias = ast3 .TypeAlias
149
+ else :
150
+ ast_TypeAlias = Any
151
+
147
152
if sys .version_info >= (3 , 10 ):
148
153
Match = ast3 .Match
149
154
MatchValue = ast3 .MatchValue
@@ -936,6 +941,14 @@ def do_func_def(
936
941
arg_types = [AnyType (TypeOfAny .from_error )] * len (args )
937
942
return_type = AnyType (TypeOfAny .from_error )
938
943
else :
944
+ if sys .version_info >= (3 , 12 ) and n .type_params :
945
+ self .fail (
946
+ ErrorMessage ("PEP 695 generics are not yet supported" , code = codes .VALID_TYPE ),
947
+ n .type_params [0 ].lineno ,
948
+ n .type_params [0 ].col_offset ,
949
+ blocker = False ,
950
+ )
951
+
939
952
arg_types = [a .type_annotation for a in args ]
940
953
return_type = TypeConverter (
941
954
self .errors , line = n .returns .lineno if n .returns else lineno
@@ -1110,6 +1123,14 @@ def visit_ClassDef(self, n: ast3.ClassDef) -> ClassDef:
1110
1123
self .class_and_function_stack .append ("C" )
1111
1124
keywords = [(kw .arg , self .visit (kw .value )) for kw in n .keywords if kw .arg ]
1112
1125
1126
+ if sys .version_info >= (3 , 12 ) and n .type_params :
1127
+ self .fail (
1128
+ ErrorMessage ("PEP 695 generics are not yet supported" , code = codes .VALID_TYPE ),
1129
+ n .type_params [0 ].lineno ,
1130
+ n .type_params [0 ].col_offset ,
1131
+ blocker = False ,
1132
+ )
1133
+
1113
1134
cdef = ClassDef (
1114
1135
n .name ,
1115
1136
self .as_required_block (n .body ),
@@ -1717,6 +1738,16 @@ def visit_MatchOr(self, n: MatchOr) -> OrPattern:
1717
1738
node = OrPattern ([self .visit (pattern ) for pattern in n .patterns ])
1718
1739
return self .set_line (node , n )
1719
1740
1741
+ def visit_TypeAlias (self , n : ast_TypeAlias ) -> AssignmentStmt :
1742
+ self .fail (
1743
+ ErrorMessage ("PEP 695 type aliases are not yet supported" , code = codes .VALID_TYPE ),
1744
+ n .lineno ,
1745
+ n .col_offset ,
1746
+ blocker = False ,
1747
+ )
1748
+ node = AssignmentStmt ([NameExpr (n .name .id )], self .visit (n .value ))
1749
+ return self .set_line (node , n )
1750
+
1720
1751
1721
1752
class TypeConverter :
1722
1753
def __init__ (
0 commit comments