(node: Any, func_name: str)
| 122 | |
| 123 | |
| 124 | def is_called(node: Any, func_name: str) -> bool: |
| 125 | # Check if it calls into a func |
| 126 | if isinstance(node, doc.Call): |
| 127 | # Recursive call was found |
| 128 | if isinstance(node.func, doc.Name) and node.func.id == func_name: |
| 129 | return True |
| 130 | elif isinstance(node, list | tuple): |
| 131 | for stmt in node: |
| 132 | if is_called(stmt, func_name): |
| 133 | return True |
| 134 | elif isinstance(node, doc.AnnAssign | doc.Assign | doc.Return | doc.Expr): |
| 135 | return is_called(node.value, func_name) |
| 136 | elif isinstance(node, doc.With): |
| 137 | return is_called(node.body, func_name) |
| 138 | elif isinstance(node, doc.If): |
| 139 | smts = [] |
| 140 | if node.body is not None: |
| 141 | smts = smts + list(node.body) |
| 142 | if node.orelse is not None: |
| 143 | smts = smts + list(node.orelse) |
| 144 | return is_called(smts, func_name) |
| 145 | return False |
| 146 | |
| 147 | |
| 148 | def is_recursive(node: doc.FunctionDef) -> bool: |
no outgoing calls
no test coverage detected
searching dependent graphs…