From a9da16892dba400a8229a92f449d87c92528320c Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 29 Jun 2025 15:39:09 -0400 Subject: [PATCH] Mk `Aid` hashable, use pretty-`.__repr__()` Hash on the `.uuid: str` and delegate verbatim to `msg.pretty_struct.Struct`'s equiv method. --- tractor/msg/types.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tractor/msg/types.py b/tractor/msg/types.py index f077f132..17d99449 100644 --- a/tractor/msg/types.py +++ b/tractor/msg/types.py @@ -177,6 +177,16 @@ class Aid( f'{self.name}@{self.pid!r}' ) + # mk hashable via `.uuid` + def __hash__(self) -> int: + return hash(self.uuid) + + def __eq__(self, other: Aid) -> bool: + return self.uuid == other.uuid + + # use pretty fmt since often repr-ed for console/log + __repr__ = pretty_struct.Struct.__repr__ + class SpawnSpec( pretty_struct.Struct,