insndb/core: replace walkability check
authorDmitry Selyutin <ghostmansd@gmail.com>
Sat, 10 Jun 2023 17:01:52 +0000 (20:01 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sat, 10 Jun 2023 18:04:59 +0000 (21:04 +0300)
src/openpower/insndb/core.py

index 2c7abe79dc36a2f137dc4296e895784c4fbd2343..68fdfe20e8a30eb780ae2761ae41eb99326838fa 100644 (file)
@@ -81,7 +81,7 @@ class DataclassMeta(type):
         return _dataclasses.dataclass(cls, eq=True, frozen=True)
 
 
-class Dataclass(metaclass=DataclassMeta):
+class Dataclass(Node, metaclass=DataclassMeta):
     @walkmethod
     def walk(clsself, match=None):
         if match is None:
@@ -171,7 +171,7 @@ def walk(root, match=None):
 
 def visit(visitor, node):
     with visitor(node=node):
-        if hasattr(node, "walk"):
+        if isinstance(node, Node):
             for subnode in node.walk():
                 visit(visitor=visitor, node=subnode)