all: decouple context visitor
authorDmitry Selyutin <ghostmansd@gmail.com>
Fri, 16 Jun 2023 20:42:45 +0000 (23:42 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Fri, 16 Jun 2023 20:42:45 +0000 (23:42 +0300)
src/mdis/visitor.py

index f70b5c52392a8f3fe4ee9bd0056af00cc04dca2f..8eb1f2219fb6fa5114d44e7de61b5d3439e6f005 100644 (file)
@@ -8,7 +8,13 @@ class VisitorMeta(_dispatcher.DispatcherMeta):
 
 
 class Visitor(_dispatcher.Dispatcher, metaclass=VisitorMeta):
+    @_dispatcher.Hook(object)
+    def dispatch_object(self, instance):
+        return instance
+
+
+class ContextVisitor(Visitor):
     @_dispatcher.Hook(object)
     @_contextlib.contextmanager
     def dispatch_object(self, instance):
-        yield instance
+        yield super().__call__(instance=instance)