@@ -222,6 +222,7 @@ impl ToPyWrapper for ast::Stmt<SourceRange> {
222222 Self :: Return ( cons) => cons. to_py_wrapper ( py) ,
223223 Self :: Delete ( cons) => cons. to_py_wrapper ( py) ,
224224 Self :: Assign ( cons) => cons. to_py_wrapper ( py) ,
225+ Self :: TypeAlias ( cons) => cons. to_py_wrapper ( py) ,
225226 Self :: AugAssign ( cons) => cons. to_py_wrapper ( py) ,
226227 Self :: AnnAssign ( cons) => cons. to_py_wrapper ( py) ,
227228 Self :: For ( cons) => cons. to_py_wrapper ( py) ,
@@ -310,6 +311,12 @@ impl StmtFunctionDef {
310311 fn get_type_comment ( & self , py : Python ) -> PyResult < PyObject > {
311312 self . 0 . type_comment . to_py_wrapper ( py)
312313 }
314+
315+ #[ getter]
316+ #[ inline]
317+ fn get_type_params ( & self , py : Python ) -> PyResult < PyObject > {
318+ self . 0 . type_params . to_py_wrapper ( py)
319+ }
313320}
314321
315322#[ pyclass( module="rustpython_ast.located" , name="_AsyncFunctionDef" , extends=Stmt , frozen) ]
@@ -375,6 +382,12 @@ impl StmtAsyncFunctionDef {
375382 fn get_type_comment ( & self , py : Python ) -> PyResult < PyObject > {
376383 self . 0 . type_comment . to_py_wrapper ( py)
377384 }
385+
386+ #[ getter]
387+ #[ inline]
388+ fn get_type_params ( & self , py : Python ) -> PyResult < PyObject > {
389+ self . 0 . type_params . to_py_wrapper ( py)
390+ }
378391}
379392
380393#[ pyclass( module="rustpython_ast.located" , name="_ClassDef" , extends=Stmt , frozen) ]
@@ -434,6 +447,12 @@ impl StmtClassDef {
434447 fn get_decorator_list ( & self , py : Python ) -> PyResult < PyObject > {
435448 self . 0 . decorator_list . to_py_wrapper ( py)
436449 }
450+
451+ #[ getter]
452+ #[ inline]
453+ fn get_type_params ( & self , py : Python ) -> PyResult < PyObject > {
454+ self . 0 . type_params . to_py_wrapper ( py)
455+ }
437456}
438457
439458#[ pyclass( module="rustpython_ast.located" , name="_Return" , extends=Stmt , frozen) ]
@@ -553,6 +572,53 @@ impl StmtAssign {
553572 }
554573}
555574
575+ #[ pyclass( module="rustpython_ast.located" , name="_TypeAlias" , extends=Stmt , frozen) ]
576+ #[ derive( Clone , Debug ) ]
577+ pub struct StmtTypeAlias ( pub & ' static ast:: StmtTypeAlias < SourceRange > ) ;
578+
579+ impl From < & ' static ast:: StmtTypeAlias < SourceRange > > for StmtTypeAlias {
580+ fn from ( node : & ' static ast:: StmtTypeAlias < SourceRange > ) -> Self {
581+ StmtTypeAlias ( node)
582+ }
583+ }
584+
585+ impl ToPyObject for StmtTypeAlias {
586+ fn to_object ( & self , py : Python ) -> PyObject {
587+ let initializer = PyClassInitializer :: from ( Ast )
588+ . add_subclass ( Stmt )
589+ . add_subclass ( self . clone ( ) ) ;
590+ Py :: new ( py, initializer) . unwrap ( ) . into_py ( py)
591+ }
592+ }
593+
594+ impl ToPyWrapper for ast:: StmtTypeAlias < SourceRange > {
595+ #[ inline]
596+ fn to_py_wrapper ( & ' static self , py : Python ) -> PyResult < Py < PyAny > > {
597+ Ok ( StmtTypeAlias ( self ) . to_object ( py) )
598+ }
599+ }
600+
601+ #[ pymethods]
602+ impl StmtTypeAlias {
603+ #[ getter]
604+ #[ inline]
605+ fn get_name ( & self , py : Python ) -> PyResult < PyObject > {
606+ self . 0 . name . to_py_wrapper ( py)
607+ }
608+
609+ #[ getter]
610+ #[ inline]
611+ fn get_type_params ( & self , py : Python ) -> PyResult < PyObject > {
612+ self . 0 . type_params . to_py_wrapper ( py)
613+ }
614+
615+ #[ getter]
616+ #[ inline]
617+ fn get_value ( & self , py : Python ) -> PyResult < PyObject > {
618+ self . 0 . value . to_py_wrapper ( py)
619+ }
620+ }
621+
556622#[ pyclass( module="rustpython_ast.located" , name="_AugAssign" , extends=Stmt , frozen) ]
557623#[ derive( Clone , Debug ) ]
558624pub struct StmtAugAssign ( pub & ' static ast:: StmtAugAssign < SourceRange > ) ;
@@ -3993,6 +4059,152 @@ impl TypeIgnoreTypeIgnore {
39934059 }
39944060}
39954061
4062+ #[ pyclass( module="rustpython_ast.located" , name="_type_param" , extends=super :: Ast , frozen, subclass) ]
4063+ #[ derive( Clone , Debug ) ]
4064+ pub struct TypeParam ;
4065+
4066+ impl From < & ' static ast:: TypeParam < SourceRange > > for TypeParam {
4067+ fn from ( _node : & ' static ast:: TypeParam < SourceRange > ) -> Self {
4068+ TypeParam
4069+ }
4070+ }
4071+
4072+ #[ pymethods]
4073+ impl TypeParam {
4074+ #[ new]
4075+ fn new ( ) -> PyClassInitializer < Self > {
4076+ PyClassInitializer :: from ( Ast ) . add_subclass ( Self )
4077+ }
4078+ }
4079+ impl ToPyObject for TypeParam {
4080+ fn to_object ( & self , py : Python ) -> PyObject {
4081+ let initializer = Self :: new ( ) ;
4082+ Py :: new ( py, initializer) . unwrap ( ) . into_py ( py)
4083+ }
4084+ }
4085+
4086+ impl ToPyWrapper for ast:: TypeParam < SourceRange > {
4087+ #[ inline]
4088+ fn to_py_wrapper ( & ' static self , py : Python ) -> PyResult < Py < PyAny > > {
4089+ match & self {
4090+ Self :: TypeVar ( cons) => cons. to_py_wrapper ( py) ,
4091+ Self :: ParamSpec ( cons) => cons. to_py_wrapper ( py) ,
4092+ Self :: TypeVarTuple ( cons) => cons. to_py_wrapper ( py) ,
4093+ }
4094+ }
4095+ }
4096+
4097+ #[ pyclass( module="rustpython_ast.located" , name="_TypeVar" , extends=TypeParam , frozen) ]
4098+ #[ derive( Clone , Debug ) ]
4099+ pub struct TypeParamTypeVar ( pub & ' static ast:: TypeParamTypeVar < SourceRange > ) ;
4100+
4101+ impl From < & ' static ast:: TypeParamTypeVar < SourceRange > > for TypeParamTypeVar {
4102+ fn from ( node : & ' static ast:: TypeParamTypeVar < SourceRange > ) -> Self {
4103+ TypeParamTypeVar ( node)
4104+ }
4105+ }
4106+
4107+ impl ToPyObject for TypeParamTypeVar {
4108+ fn to_object ( & self , py : Python ) -> PyObject {
4109+ let initializer = PyClassInitializer :: from ( Ast )
4110+ . add_subclass ( TypeParam )
4111+ . add_subclass ( self . clone ( ) ) ;
4112+ Py :: new ( py, initializer) . unwrap ( ) . into_py ( py)
4113+ }
4114+ }
4115+
4116+ impl ToPyWrapper for ast:: TypeParamTypeVar < SourceRange > {
4117+ #[ inline]
4118+ fn to_py_wrapper ( & ' static self , py : Python ) -> PyResult < Py < PyAny > > {
4119+ Ok ( TypeParamTypeVar ( self ) . to_object ( py) )
4120+ }
4121+ }
4122+
4123+ #[ pymethods]
4124+ impl TypeParamTypeVar {
4125+ #[ getter]
4126+ #[ inline]
4127+ fn get_name ( & self , py : Python ) -> PyResult < PyObject > {
4128+ self . 0 . name . to_py_wrapper ( py)
4129+ }
4130+
4131+ #[ getter]
4132+ #[ inline]
4133+ fn get_bound ( & self , py : Python ) -> PyResult < PyObject > {
4134+ self . 0 . bound . to_py_wrapper ( py)
4135+ }
4136+ }
4137+
4138+ #[ pyclass( module="rustpython_ast.located" , name="_ParamSpec" , extends=TypeParam , frozen) ]
4139+ #[ derive( Clone , Debug ) ]
4140+ pub struct TypeParamParamSpec ( pub & ' static ast:: TypeParamParamSpec < SourceRange > ) ;
4141+
4142+ impl From < & ' static ast:: TypeParamParamSpec < SourceRange > > for TypeParamParamSpec {
4143+ fn from ( node : & ' static ast:: TypeParamParamSpec < SourceRange > ) -> Self {
4144+ TypeParamParamSpec ( node)
4145+ }
4146+ }
4147+
4148+ impl ToPyObject for TypeParamParamSpec {
4149+ fn to_object ( & self , py : Python ) -> PyObject {
4150+ let initializer = PyClassInitializer :: from ( Ast )
4151+ . add_subclass ( TypeParam )
4152+ . add_subclass ( self . clone ( ) ) ;
4153+ Py :: new ( py, initializer) . unwrap ( ) . into_py ( py)
4154+ }
4155+ }
4156+
4157+ impl ToPyWrapper for ast:: TypeParamParamSpec < SourceRange > {
4158+ #[ inline]
4159+ fn to_py_wrapper ( & ' static self , py : Python ) -> PyResult < Py < PyAny > > {
4160+ Ok ( TypeParamParamSpec ( self ) . to_object ( py) )
4161+ }
4162+ }
4163+
4164+ #[ pymethods]
4165+ impl TypeParamParamSpec {
4166+ #[ getter]
4167+ #[ inline]
4168+ fn get_name ( & self , py : Python ) -> PyResult < PyObject > {
4169+ self . 0 . name . to_py_wrapper ( py)
4170+ }
4171+ }
4172+
4173+ #[ pyclass( module="rustpython_ast.located" , name="_TypeVarTuple" , extends=TypeParam , frozen) ]
4174+ #[ derive( Clone , Debug ) ]
4175+ pub struct TypeParamTypeVarTuple ( pub & ' static ast:: TypeParamTypeVarTuple < SourceRange > ) ;
4176+
4177+ impl From < & ' static ast:: TypeParamTypeVarTuple < SourceRange > > for TypeParamTypeVarTuple {
4178+ fn from ( node : & ' static ast:: TypeParamTypeVarTuple < SourceRange > ) -> Self {
4179+ TypeParamTypeVarTuple ( node)
4180+ }
4181+ }
4182+
4183+ impl ToPyObject for TypeParamTypeVarTuple {
4184+ fn to_object ( & self , py : Python ) -> PyObject {
4185+ let initializer = PyClassInitializer :: from ( Ast )
4186+ . add_subclass ( TypeParam )
4187+ . add_subclass ( self . clone ( ) ) ;
4188+ Py :: new ( py, initializer) . unwrap ( ) . into_py ( py)
4189+ }
4190+ }
4191+
4192+ impl ToPyWrapper for ast:: TypeParamTypeVarTuple < SourceRange > {
4193+ #[ inline]
4194+ fn to_py_wrapper ( & ' static self , py : Python ) -> PyResult < Py < PyAny > > {
4195+ Ok ( TypeParamTypeVarTuple ( self ) . to_object ( py) )
4196+ }
4197+ }
4198+
4199+ #[ pymethods]
4200+ impl TypeParamTypeVarTuple {
4201+ #[ getter]
4202+ #[ inline]
4203+ fn get_name ( & self , py : Python ) -> PyResult < PyObject > {
4204+ self . 0 . name . to_py_wrapper ( py)
4205+ }
4206+ }
4207+
39964208impl ToPyWrapper for ast:: ExprContext {
39974209 #[ inline]
39984210 fn to_py_wrapper ( & self , py : Python ) -> PyResult < Py < PyAny > > {
@@ -4303,6 +4515,7 @@ pub fn add_to_module(py: Python, m: &PyModule) -> PyResult<()> {
43034515 super :: init_type :: < StmtReturn , ast:: StmtReturn > ( py, m) ?;
43044516 super :: init_type :: < StmtDelete , ast:: StmtDelete > ( py, m) ?;
43054517 super :: init_type :: < StmtAssign , ast:: StmtAssign > ( py, m) ?;
4518+ super :: init_type :: < StmtTypeAlias , ast:: StmtTypeAlias > ( py, m) ?;
43064519 super :: init_type :: < StmtAugAssign , ast:: StmtAugAssign > ( py, m) ?;
43074520 super :: init_type :: < StmtAnnAssign , ast:: StmtAnnAssign > ( py, m) ?;
43084521 super :: init_type :: < StmtFor , ast:: StmtFor > ( py, m) ?;
@@ -4409,5 +4622,9 @@ pub fn add_to_module(py: Python, m: &PyModule) -> PyResult<()> {
44094622 super :: init_type :: < PatternMatchOr , ast:: PatternMatchOr > ( py, m) ?;
44104623 super :: init_type :: < TypeIgnore , ast:: TypeIgnore > ( py, m) ?;
44114624 super :: init_type :: < TypeIgnoreTypeIgnore , ast:: TypeIgnoreTypeIgnore > ( py, m) ?;
4625+ super :: init_type :: < TypeParam , ast:: TypeParam > ( py, m) ?;
4626+ super :: init_type :: < TypeParamTypeVar , ast:: TypeParamTypeVar > ( py, m) ?;
4627+ super :: init_type :: < TypeParamParamSpec , ast:: TypeParamParamSpec > ( py, m) ?;
4628+ super :: init_type :: < TypeParamTypeVarTuple , ast:: TypeParamTypeVarTuple > ( py, m) ?;
44124629 Ok ( ( ) )
44134630}
0 commit comments