core: simplify hooks representation
authorDmitry Selyutin <ghostmansd@gmail.com>
Tue, 13 Jun 2023 22:22:55 +0000 (01:22 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Tue, 13 Jun 2023 22:23:29 +0000 (01:23 +0300)
src/mdis/core.py

index 61c4fd831526837183140c8e3928c3f2f8acd092..7f257c86a60aabff9cc107c864933b1fd16361dd 100644 (file)
@@ -10,7 +10,14 @@ class TypeidHook(object):
         yield from self.__typeids
 
     def __repr__(self):
-        return f"{self.__class__.__name__}({self.__typeids!r})"
+        names = []
+        for typeid in self.__typeids:
+            name = typeid.__qualname__
+            module = typeid.__module__
+            if module not in ("builtins",):
+                name = f"{module}.{name}"
+            names.append(name)
+        return f"<{', '.join(names)}>"
 
     def __call__(self, call):
         if not callable(call):
@@ -32,7 +39,7 @@ class CallHook(object):
         yield from self.__typeids
 
     def __repr__(self):
-        return f"{self.__class__.__name__}(call={self.__call!r}, typeids={self.__typeids!r})"
+        return repr(self.__typeids)
 
     def __call__(self, dispatcher, instance):
         return self.__call(dispatcher, instance)