Apply the AST transformations from self.ast_transformers Parameters ---------- node : ast.Node The root node to be transformed. Typically called with the ast.Module produced by parsing user input. Returns ------- A
(self, node)
| 3192 | return cell |
| 3193 | |
| 3194 | def transform_ast(self, node): |
| 3195 | """Apply the AST transformations from self.ast_transformers |
| 3196 | |
| 3197 | Parameters |
| 3198 | ---------- |
| 3199 | node : ast.Node |
| 3200 | The root node to be transformed. Typically called with the ast.Module |
| 3201 | produced by parsing user input. |
| 3202 | |
| 3203 | Returns |
| 3204 | ------- |
| 3205 | An ast.Node corresponding to the node it was called with. Note that it |
| 3206 | may also modify the passed object, so don't rely on references to the |
| 3207 | original AST. |
| 3208 | """ |
| 3209 | for transformer in self.ast_transformers: |
| 3210 | try: |
| 3211 | node = transformer.visit(node) |
| 3212 | except InputRejected: |
| 3213 | # User-supplied AST transformers can reject an input by raising |
| 3214 | # an InputRejected. Short-circuit in this case so that we |
| 3215 | # don't unregister the transform. |
| 3216 | raise |
| 3217 | except Exception: |
| 3218 | warn("AST transformer %r threw an error. It will be unregistered." % transformer) |
| 3219 | self.ast_transformers.remove(transformer) |
| 3220 | |
| 3221 | if self.ast_transformers: |
| 3222 | ast.fix_missing_locations(node) |
| 3223 | return node |
| 3224 | |
| 3225 | async def run_ast_nodes(self, nodelist:ListType[AST], cell_name:str, interactivity='last_expr', |
| 3226 | compiler=compile, result=None): |
no test coverage detected