@@ -144,6 +144,11 @@ def ast3_parse(
144144NamedExpr = ast3 .NamedExpr
145145Constant = ast3 .Constant
146146
147+ if sys .version_info >= (3 , 12 ):
148+ ast_TypeAlias = ast3 .TypeAlias
149+ else :
150+ ast_TypeAlias = Any
151+
147152if sys .version_info >= (3 , 10 ):
148153 Match = ast3 .Match
149154 MatchValue = ast3 .MatchValue
@@ -936,6 +941,14 @@ def do_func_def(
936941 arg_types = [AnyType (TypeOfAny .from_error )] * len (args )
937942 return_type = AnyType (TypeOfAny .from_error )
938943 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+
939952 arg_types = [a .type_annotation for a in args ]
940953 return_type = TypeConverter (
941954 self .errors , line = n .returns .lineno if n .returns else lineno
@@ -1110,6 +1123,14 @@ def visit_ClassDef(self, n: ast3.ClassDef) -> ClassDef:
11101123 self .class_and_function_stack .append ("C" )
11111124 keywords = [(kw .arg , self .visit (kw .value )) for kw in n .keywords if kw .arg ]
11121125
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+
11131134 cdef = ClassDef (
11141135 n .name ,
11151136 self .as_required_block (n .body ),
@@ -1717,6 +1738,16 @@ def visit_MatchOr(self, n: MatchOr) -> OrPattern:
17171738 node = OrPattern ([self .visit (pattern ) for pattern in n .patterns ])
17181739 return self .set_line (node , n )
17191740
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+
17201751
17211752class TypeConverter :
17221753 def __init__ (
0 commit comments