class Node:
@walkmethod
- def walk(clsself, match=None):
+ def walk(clsself, match=lambda _: True):
yield from ()
class Dataclass(Node, metaclass=DataclassMeta):
@walkmethod
- def walk(clsself, match=None):
- if match is None:
- match = lambda subnode: True
-
+ def walk(clsself, match=lambda _: True):
def field_type(field):
return field.type
return super().__init_subclass__()
@walkmethod
- def walk(clsself, match=None):
- if match is None:
- match = lambda subnode: True
-
+ def walk(clsself, match=lambda _: True):
if isinstance(clsself, type):
yield ("[]", clsself.__datatype)
else:
raise NotImplementedError()
@walkmethod
- def walk(clsself, match=None):
- if match is None:
- match = lambda subnode: True
-
+ def walk(clsself, match=lambda _: True):
if isinstance(clsself, type):
yield ("{}", clsself.__datatype)
else:
return VisitorMethod(nodecls=self.__nodecls, method=method)
-def walk(root, match=None):
+def walk(root, match=lambda _: True):
pairs = _collections.deque([root])
while pairs:
(path, node) = pairs.popleft()
yield (path, node)
-def visit(visitor, node, path="/"):
+def visit(visitor, node, path="/", match=lambda _: True):
with visitor(path=path, node=node):
if isinstance(node, Node):
- for (subpath, subnode) in node.walk():
+ for (subpath, subnode) in node.walk(match=match):
visit(visitor=visitor, path=subpath, node=subnode)
return super().__init__()
@walkmethod
- def walk(clsself, match=None):
- if match is None:
- match = lambda subnode: True
-
+ def walk(clsself, match=lambda _: True):
if isinstance(clsself, type):
yield ("records", Records)
else: