Reset the context of a node and all child nodes. Per default the parser will all generate nodes that have a 'load' context as it's the most common one. This method is used in the parser to set assignment targets and other nodes to a store context.
(self, ctx: str)
| 204 | yield from child.find_all(node_type) |
| 205 | |
| 206 | def set_ctx(self, ctx: str) -> "Node": |
| 207 | """Reset the context of a node and all child nodes. Per default the |
| 208 | parser will all generate nodes that have a 'load' context as it's the |
| 209 | most common one. This method is used in the parser to set assignment |
| 210 | targets and other nodes to a store context. |
| 211 | """ |
| 212 | todo = deque([self]) |
| 213 | while todo: |
| 214 | node = todo.popleft() |
| 215 | if "ctx" in node.fields: |
| 216 | node.ctx = ctx # type: ignore |
| 217 | todo.extend(node.iter_child_nodes()) |
| 218 | return self |
| 219 | |
| 220 | def set_lineno(self, lineno: int, override: bool = False) -> "Node": |
| 221 | """Set the line numbers of the node and children.""" |
no test coverage detected