walker: prevent nested walking
authorDmitry Selyutin <ghostmansd@gmail.com>
Fri, 23 Jun 2023 08:26:51 +0000 (11:26 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Fri, 23 Jun 2023 08:26:58 +0000 (11:26 +0300)
src/mdis/walker.py

index 3605d0a5e9a861917d844e37cb003e5752484b5a..ecc9f3b86a04c674e3ce6b04b59762de7b999eeb 100644 (file)
@@ -49,13 +49,11 @@ class Walker(dispatcher.Dispatcher, metaclass=WalkerMeta):
     def dispatch_ordered_sequence(self, node):
         for (index, item) in enumerate(node):
             yield (item, node, index, IndexPath)
-            yield from self(item)
 
     @dispatcher.Hook(set, frozenset)
     def dispatch_unordered_sequence(self, node):
         for item in node:
             yield (item, node, item, HashPath)
-            yield from self(item)
 
     @dispatcher.Hook(dataclasses.is_dataclass)
     def dispatch_dataclass(self, node):
@@ -63,16 +61,13 @@ class Walker(dispatcher.Dispatcher, metaclass=WalkerMeta):
             key = field.name
             value = getattr(node, key)
             yield (value, node, key, AttributePath)
-            yield from self(value)
 
     @dispatcher.Hook(dict)
     def dispatch_mapping(self, node):
         for (key, value) in node.items():
             yield (key, node, key, HashPath)
-            yield from self(key)
             yield (value, node, key, IndexPath)
-            yield from self(value)
 
     @dispatcher.Hook(object)
-    def dispatch_object(self, node, path=()):
+    def dispatch_object(self, node):
         yield from ()