MCPcopy
hub / github.com/psf/black / visit_default

Method visit_default

tests/data/miscellaneous/debug_visitor.py:5–23  ·  view source on GitHub ↗
(self, node: LN)

Source from the content-addressed store, hash-verified

3 tree_depth: int = 0
4
5 def visit_default(self, node: LN) -> Iterator[T]:
6 indent = ' ' * (2 * self.tree_depth)
7 if isinstance(node, Node):
8 _type = type_repr(node.type)
9 out(f'{indent}{_type}', fg='yellow')
10 self.tree_depth += 1
11 for child in node.children:
12 yield from self.visit(child)
13
14 self.tree_depth -= 1
15 out(f'{indent}/{_type}', fg='yellow', bold=False)
16 else:
17 _type = token.tok_name.get(node.type, str(node.type))
18 out(f'{indent}{_type}', fg='blue', nl=False)
19 if node.prefix:
20 # We don't have to handle prefixes for `Node` objects since
21 # that delegates to the first child anyway.
22 out(f' {node.prefix!r}', fg='green', bold=False, nl=False)
23 out(f' {node.value!r}', fg='blue', bold=False)
24
25 @classmethod
26 def show(cls, code: str) -> None:

Callers

nothing calls this directly

Calls 3

type_reprFunction · 0.85
outFunction · 0.85
visitMethod · 0.80

Tested by

no test coverage detected