@@ -338,17 +338,15 @@ def simple_sum(self, sum, type, depth):
338338            prefix  =  "" 
339339        for  cons  in  sum .types :
340340            self .emit (
341-                 textwrap .dedent (
342-                     f""" 
343-                     #[inline] 
344-                     pub const fn { prefix } { rust_field_name (cons .name )}  (&self) -> Option<{ rust_name } { cons .name }  > {{ 
345-                         match self {{ 
346-                             { rust_name }  ::{ cons .name }   => Some({ rust_name } { cons .name }  ), 
347-                             _ => None, 
348-                         }} 
341+                 f""" 
342+                 #[inline] 
343+                 pub const fn { prefix } { rust_field_name (cons .name )}  (&self) -> Option<{ rust_name } { cons .name }  > {{ 
344+                     match self {{ 
345+                         { rust_name }  ::{ cons .name }   => Some({ rust_name } { cons .name }  ), 
346+                         _ => None, 
349347                    }} 
350-                     """  
351-                 ) ,
348+                 }}  
349+                 """  ,
352350                depth ,
353351            )
354352        self .emit ("}" , depth )
@@ -415,19 +413,17 @@ def sum_subtype_struct(self, sum_type_info, t, rust_name, depth):
415413        self .emit ("}" , depth )
416414        field_names  =  [f'"{ f .name }  "'  for  f  in  t .fields ]
417415        self .emit (
418-             textwrap .dedent (
419-                 f""" 
420-                 impl<R> Node for { payload_name }  <R> {{ 
421-                     const NAME: &'static str = "{ t .name }  "; 
422-                     const FIELD_NAMES: &'static [&'static str] = &[{ ', ' .join (field_names )}  ]; 
423-                 }} 
424-                 impl<R> From<{ payload_name }  <R>> for { rust_name }  <R> {{ 
425-                     fn from(payload: { payload_name }  <R>) -> Self {{ 
426-                         { rust_name }  ::{ t .name }  (payload) 
427-                     }} 
416+             f""" 
417+             impl<R> Node for { payload_name }  <R> {{ 
418+                 const NAME: &'static str = "{ t .name }  "; 
419+                 const FIELD_NAMES: &'static [&'static str] = &[{ ', ' .join (field_names )}  ]; 
420+             }} 
421+             impl<R> From<{ payload_name }  <R>> for { rust_name }  <R> {{ 
422+                 fn from(payload: { payload_name }  <R>) -> Self {{ 
423+                     { rust_name }  ::{ t .name }  (payload) 
428424                }} 
429-                 """  
430-             ) ,
425+             }}  
426+             """  ,
431427            depth ,
432428        )
433429
@@ -982,12 +978,12 @@ def visitSum(self, sum, type):
982978                #[inline] 
983979                fn to_pyo3_ast(&self, { "_"  if  simple  else  "" }  py: Python) -> PyResult<Py<PyAny>> {{ 
984980                    let instance = match &self {{ 
985-                          """ ,
981+             """ ,
986982            0 ,
987983        )
988984        for  cons  in  sum .types :
989985            self .emit (
990-                 f""" crate::{ rust_name }  ::{ cons .name }  (cons) => cons.to_pyo3_ast(py)?,"" " ,
986+                 f"crate::{ rust_name }  ::{ cons .name }  (cons) => cons.to_pyo3_ast(py)?," ,
991987                1 ,
992988            )
993989        self .emit (
@@ -1036,9 +1032,7 @@ def emit_to_pyo3_with_fields(self, cons, type, name):
10361032                    3 ,
10371033                )
10381034            self .emit (
1039-                 """ 
1040-                         ))?; 
1041-                 """ ,
1035+                 "))?;" ,
10421036                0 ,
10431037            )
10441038        else :
@@ -1119,42 +1113,38 @@ def emit_class(self, name, rust_name, simple, base="super::AST"):
11191113            into  =  f"{ rust_name }  (node)" 
11201114
11211115        self .emit (
1122-             textwrap .dedent (
1123-                 f""" 
1124-                 #[pyclass(module="{ self .module_name }  ", name="_{ name }  ", extends={ base }  , frozen{ subclass }  )] 
1125-                 #[derive(Clone, Debug)] 
1126-                 pub struct { rust_name }   { body }  ; 
1116+             f""" 
1117+             #[pyclass(module="{ self .module_name }  ", name="_{ name }  ", extends={ base }  , frozen{ subclass }  )] 
1118+             #[derive(Clone, Debug)] 
1119+             pub struct { rust_name }   { body }  ; 
11271120
1128-                 impl From<{ self .ref_def }   crate::{ rust_name } { generics }  > for { rust_name }   {{ 
1129-                     fn from({ ""  if  body  else  "_" }  node: { self .ref_def }   crate::{ rust_name } { generics }  ) -> Self {{ 
1130-                         { into }  
1131-                     }} 
1121+             impl From<{ self .ref_def }   crate::{ rust_name } { generics }  > for { rust_name }   {{ 
1122+                 fn from({ ""  if  body  else  "_" }  node: { self .ref_def }   crate::{ rust_name } { generics }  ) -> Self {{ 
1123+                     { into }  
11321124                }} 
1133-                 """  
1134-             ) ,
1125+             }}  
1126+             """  ,
11351127            0 ,
11361128        )
11371129        if  subclass :
11381130            self .emit (
1139-                 textwrap .dedent (
1140-                     f""" 
1141-                     #[pymethods] 
1142-                     impl { rust_name }   {{ 
1143-                         #[new] 
1144-                         fn new() -> PyClassInitializer<Self> {{ 
1145-                             PyClassInitializer::from(AST) 
1146-                                 .add_subclass(Self) 
1147-                         }} 
1148- 
1131+                 f""" 
1132+                 #[pymethods] 
1133+                 impl { rust_name }   {{ 
1134+                     #[new] 
1135+                     fn new() -> PyClassInitializer<Self> {{ 
1136+                         PyClassInitializer::from(AST) 
1137+                             .add_subclass(Self) 
11491138                    }} 
1150-                     impl ToPyObject for { rust_name }   {{ 
1151-                         fn to_object(&self, py: Python) -> PyObject {{ 
1152-                             let initializer = Self::new(); 
1153-                             Py::new(py, initializer).unwrap().into_py(py) 
1154-                         }} 
1139+ 
1140+                 }} 
1141+                 impl ToPyObject for { rust_name }   {{ 
1142+                     fn to_object(&self, py: Python) -> PyObject {{ 
1143+                         let initializer = Self::new(); 
1144+                         Py::new(py, initializer).unwrap().into_py(py) 
11551145                    }} 
1156-                     """  
1157-                 ) ,
1146+                 }}  
1147+                 """  ,
11581148                0 ,
11591149            )
11601150        else :
@@ -1163,18 +1153,16 @@ def emit_class(self, name, rust_name, simple, base="super::AST"):
11631153            else :
11641154                add_subclass  =  "" 
11651155            self .emit (
1166-                 textwrap .dedent (
1167-                     f""" 
1168-                     impl ToPyObject for { rust_name }   {{ 
1169-                         fn to_object(&self, py: Python) -> PyObject {{ 
1170-                             let initializer = PyClassInitializer::from(AST) 
1171-                             { add_subclass }  
1172-                             .add_subclass(self.clone()); 
1173-                             Py::new(py, initializer).unwrap().into_py(py) 
1174-                         }} 
1156+                 f""" 
1157+                 impl ToPyObject for { rust_name }   {{ 
1158+                     fn to_object(&self, py: Python) -> PyObject {{ 
1159+                         let initializer = PyClassInitializer::from(AST) 
1160+                         { add_subclass }  
1161+                         .add_subclass(self.clone()); 
1162+                         Py::new(py, initializer).unwrap().into_py(py) 
11751163                    }} 
1176-                     """  
1177-                 ) ,
1164+                 }}  
1165+                 """  ,
11781166                0 ,
11791167            )
11801168
@@ -1183,48 +1171,40 @@ def emit_class(self, name, rust_name, simple, base="super::AST"):
11831171
11841172    def  emit_getter (self , owner , type_name ):
11851173        self .emit (
1186-             textwrap .dedent (
1187-                 f""" 
1188-                 #[pymethods] 
1189-                 impl { type_name }   {{ 
1190-                 """ 
1191-             ),
1174+             f""" 
1175+             #[pymethods] 
1176+             impl { type_name }   {{ 
1177+             """ ,
11921178            0 ,
11931179        )
11941180
11951181        for  field  in  owner .fields :
11961182            self .emit (
1197-                 textwrap .dedent (
1198-                     f""" 
1199-                     #[getter] 
1200-                     #[inline] 
1201-                     fn get_{ field .name }  (&self, py: Python) -> PyResult<PyObject> {{ 
1202-                         self.0.{ rust_field (field .name )}  .to_pyo3_wrapper(py) 
1203-                     }} 
1204-                     """ 
1205-                 ),
1183+                 f""" 
1184+                 #[getter] 
1185+                 #[inline] 
1186+                 fn get_{ field .name }  (&self, py: Python) -> PyResult<PyObject> {{ 
1187+                     self.0.{ rust_field (field .name )}  .to_pyo3_wrapper(py) 
1188+                 }} 
1189+                 """ ,
12061190                3 ,
12071191            )
12081192
12091193        self .emit (
1210-             textwrap .dedent (
1211-                 """ 
1194+             """ 
12121195                } 
1213-                 """ 
1214-             ),
1196+                 """ ,
12151197            0 ,
12161198        )
12171199
12181200    def  emit_getattr (self , owner , type_name ):
12191201        self .emit (
1220-             textwrap .dedent (
1221-                 f""" 
1222-                 #[pymethods] 
1223-                 impl { type_name }   {{ 
1224-                     fn __getattr__(&self, py: Python, key: &str) -> PyResult<PyObject> {{ 
1225-                         let object: Py<PyAny> = match key {{ 
1226-                 """ 
1227-             ),
1202+             f""" 
1203+             #[pymethods] 
1204+             impl { type_name }   {{ 
1205+                 fn __getattr__(&self, py: Python, key: &str) -> PyResult<PyObject> {{ 
1206+                     let object: Py<PyAny> = match key {{ 
1207+             """ ,
12281208            0 ,
12291209        )
12301210
@@ -1235,15 +1215,13 @@ def emit_getattr(self, owner, type_name):
12351215            )
12361216
12371217        self .emit (
1238-             textwrap .dedent (
1239-                 """ 
1240-                             _ => todo!(), 
1241-                         }; 
1242-                         Ok(object) 
1243-                     } 
1218+             """ 
1219+                         _ => todo!(), 
1220+                     }; 
1221+                     Ok(object) 
12441222                } 
1245-                 """  
1246-             ) ,
1223+             }  
1224+             """  ,
12471225            0 ,
12481226        )
12491227
@@ -1309,17 +1287,17 @@ def visitConstructor(self, cons, parent, simple, depth):
13091287        if  simple :
13101288            self .emit (
13111289                f""" 
1312- #[pyclass(module="{ self .module_name }  ", name="_{ cons .name }  ", extends={ parent }  )] 
1313- pub struct { parent } { cons .name }  ; 
1314- 
1315- impl ToPyObject for { parent } { cons .name }   {{ 
1316-     fn to_object(&self, py: Python) -> PyObject {{ 
1317-         let initializer = PyClassInitializer::from(AST) 
1318-         .add_subclass({ parent }  ) 
1319-         .add_subclass(Self); 
1320-         Py::new(py, initializer).unwrap().into_py(py) 
1321-     }} 
1322- }} 
1290+                  #[pyclass(module="{ self .module_name }  ", name="_{ cons .name }  ", extends={ parent }  )]
1291+                  pub struct { parent } { cons .name }  ;
1292+ 
1293+                  impl ToPyObject for { parent } { cons .name }   {{
1294+                      fn to_object(&self, py: Python) -> PyObject {{ 
1295+                          let initializer = PyClassInitializer::from(AST) 
1296+                          .add_subclass({ parent }  ) 
1297+                          .add_subclass(Self); 
1298+                          Py::new(py, initializer).unwrap().into_py(py) 
1299+                      }} 
1300+                  }}
13231301                """ ,
13241302                depth ,
13251303            )
@@ -1659,7 +1637,8 @@ def extract_location(self, typename, depth):
16591637                let row = { row }  ; 
16601638                let column = { column }  ; 
16611639                try_location(row, column) 
1662-             }};""" ,
1640+             }}; 
1641+             """ ,
16631642            depth ,
16641643        )
16651644
@@ -1711,17 +1690,15 @@ def write(info: TypeInfo):
17111690            generics  =  "<R>" 
17121691
17131692        f .write (
1714-             textwrap .dedent (
1715-                 f""" 
1716-                 impl{ generics }   Pyo3Node for crate::generic::{ rust_name } { generics }   {{ 
1717-                     #[inline] 
1718-                     fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {{ 
1719-                         static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new(); 
1720-                         &PY_TYPE 
1721-                     }} 
1693+             f""" 
1694+             impl{ generics }   Pyo3Node for crate::generic::{ rust_name } { generics }   {{ 
1695+                 #[inline] 
1696+                 fn py_type_cache() -> &'static OnceCell<(Py<PyAny>, Py<PyAny>)> {{ 
1697+                     static PY_TYPE: OnceCell<(Py<PyAny>, Py<PyAny>)> = OnceCell::new(); 
1698+                     &PY_TYPE 
17221699                }} 
1723-                 """  
1724-             ) ,
1700+             }}  
1701+             """  ,
17251702        )
17261703
17271704    for  info  in  type_info .values ():
@@ -1832,14 +1809,12 @@ def write_pyo3_wrapper(mod, type_info, namespace, f):
18321809
18331810def  write_ast_mod (mod , type_info , f ):
18341811    f .write (
1835-         textwrap .dedent (
1836-             """ 
1837-             #![allow(clippy::all)] 
1812+         """ 
1813+         #![allow(clippy::all)] 
18381814
1839-             use super::*; 
1840-             use crate::common::ascii; 
1841-             """ 
1842-         )
1815+         use super::*; 
1816+         use crate::common::ascii; 
1817+         """ 
18431818    )
18441819
18451820    c  =  ChainOfVisitors (
0 commit comments