class Walker(dispatcher.Dispatcher, metaclass=WalkerMeta):
@dispatcher.Hook(tuple, list)
- def dispatch_ordered_sequence(self, instance, path=()):
+ def dispatch_ordered_sequence(self, instance):
for (index, item) in enumerate(instance):
- part = (PartId.Index, index)
- parts = (path + (part,))
- yield (item, parts)
- yield from self(item, path=parts)
+ yield (item, instance, index, PartId.Index)
+ yield from self(item)
@dispatcher.Hook(set, frozenset)
- def dispatch_unordered_sequence(self, instance, path=[]):
+ def dispatch_unordered_sequence(self, instance):
for item in instance:
- part = (PartId.Hash, item)
- parts = (path + (part,))
- yield (item, parts)
- yield from self(item, path=parts)
+ yield (item, instance, item, PartId.Hash)
+ yield from self(item)
@dispatcher.Hook(dataclasses.is_dataclass)
- def dispatch_dataclass(self, instance, path=[]):
+ def dispatch_dataclass(self, instance):
for field in dataclasses.fields(instance):
key = field.name
value = getattr(instance, key)
- part = (PartId.Attribute, key)
- parts = (path + (part,))
- yield (value, parts)
- yield from self(value, path=parts)
+ yield (value, instance, key, PartId.Attribute)
+ yield from self(value)
@dispatcher.Hook(dict)
- def dispatch_mapping(self, instance, path=[]):
+ def dispatch_mapping(self, instance):
for (key, value) in instance.items():
- part = (PartId.Index, key)
- parts = (path + (part,))
- yield (value, parts)
- yield from self(value, path=parts)
+ yield (key, instance, key, PartId.Hash)
+ yield from self(key)
+ yield (value, instance, key, PartId.Index)
+ yield from self(value)
@dispatcher.Hook(object)
def dispatch_object(self, instance, path=()):