MCPcopy Create free account
hub / github.com/ipython/ipython / generic_visit

Method generic_visit

IPython/core/async_helpers.py:107–122  ·  view source on GitHub ↗
(self, node)

Source from the content-addressed store, hash-verified

105 super().__init__()
106
107 def generic_visit(self, node):
108 func_types = (ast.FunctionDef, ast.AsyncFunctionDef)
109 invalid_types_by_depth = {
110 0: (ast.Return, ast.Yield, ast.YieldFrom),
111 1: (ast.Nonlocal,)
112 }
113
114 should_traverse = self.depth < max(invalid_types_by_depth.keys())
115 if isinstance(node, func_types) and should_traverse:
116 self.depth += 1
117 super().generic_visit(node)
118 self.depth -= 1
119 elif isinstance(node, invalid_types_by_depth[self.depth]):
120 raise SyntaxError()
121 else:
122 super().generic_visit(node)
123
124
125def _async_parse_cell(cell: str) -> ast.AST:

Callers 2

visit_FunctionDefMethod · 0.80
visit_IfMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected