From: Dmitry Selyutin Date: Fri, 16 Jun 2023 20:42:45 +0000 (+0300) Subject: all: decouple context visitor X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0f430159420cb0ce4c6a990eaa9448e562d04c72;p=mdis.git all: decouple context visitor --- diff --git a/src/mdis/visitor.py b/src/mdis/visitor.py index f70b5c5..8eb1f22 100644 --- a/src/mdis/visitor.py +++ b/src/mdis/visitor.py @@ -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)