fix(outbox): qualname nur fuer bound methods — plain functions behalten __name__ (test_outbox_phase5 17/17 gruen)
This commit is contained in:
+12
-5
@@ -214,16 +214,23 @@ def _json_payload(payload: dict[str, Any]) -> str:
|
|||||||
def _get_handler_name(handler: Any) -> str:
|
def _get_handler_name(handler: Any) -> str:
|
||||||
"""Extract a human-readable name from a handler callable.
|
"""Extract a human-readable name from a handler callable.
|
||||||
|
|
||||||
Prefers ``__qualname__`` (includes the owning class, e.g.
|
For bound methods (plugin handlers are bound methods, e.g.
|
||||||
``AutomationPlugin.on_contact_created``) over ``__name__`` so the
|
``AutomationPlugin.on_contact_created``) prefers ``__qualname__`` so
|
||||||
consumer registry distinguishes handlers that share a method name
|
the consumer registry distinguishes handlers that share a method name
|
||||||
across plugins (automation/unified_search/system_notif all define
|
across plugins (automation/unified_search/system_notif all define
|
||||||
``on_contact_created`` — three distinct handlers, same short name).
|
``on_contact_created`` — three distinct handlers, same short name).
|
||||||
|
|
||||||
|
Plain functions keep their ``__name__`` (nested test functions have
|
||||||
|
verbose qualnames like ``test_x.<locals>.handler``).
|
||||||
"""
|
"""
|
||||||
name = getattr(handler, "__qualname__", None)
|
if hasattr(handler, "__self__"):
|
||||||
|
qualname = getattr(handler, "__qualname__", None)
|
||||||
|
if qualname:
|
||||||
|
return qualname
|
||||||
|
name = getattr(handler, "__name__", None)
|
||||||
if name:
|
if name:
|
||||||
return name
|
return name
|
||||||
name = getattr(handler, "__name__", None)
|
name = getattr(handler, "__qualname__", None)
|
||||||
if name:
|
if name:
|
||||||
return name
|
return name
|
||||||
return str(handler)
|
return str(handler)
|
||||||
|
|||||||
Reference in New Issue
Block a user