class CustomWalker(mdis.walker.Walker):
@mdis.core.hook(dict)
- def walk_dict(self, instance):
+ def dispatch_dict(self, instance):
for (key, value) in instance.items():
yield (value, key)
yield from self((value, key))
class CustomVisitor(mdis.visitor.Visitor):
@mdis.core.hook(int)
@contextlib.contextmanager
- def visit_int(self, instance):
+ def dispatch_int(self, instance):
print("entering int")
yield (instance + 42)
print("leaving int")
@mdis.core.hook(str)
@contextlib.contextmanager
- def visit_str(self, instance):
+ def dispatch_str(self, instance):
print("entering str")
yield f"!!!{instance}!!!"
print("leaving str")
@mdis.core.hook(object)
@contextlib.contextmanager
- def visit_object(self, instance):
+ def dispatch_object(self, instance):
print("entering object")
yield instance
print("leaving object")