diff --git a/Products/ZenHub/server/events.py b/Products/ZenHub/server/events.py index 6c33cc5f91..07df019e08 100644 --- a/Products/ZenHub/server/events.py +++ b/Products/ZenHub/server/events.py @@ -73,18 +73,18 @@ class _CompletedData(_StartedData): result = attr.ib(default=_UNSPECIFIED) def __attrs_post_init__(self): - if ( - sum( - 1 - for name in ("result", "error", "retry") - if getattr(self, name) is _UNSPECIFIED - ) - != 2 - ): + unspecified = tuple( + name + for name in ("result", "error", "retry") + if getattr(self, name) is _UNSPECIFIED + ) + if len(unspecified) != 2: raise TypeError( "At least one of fields 'result', 'retry', and 'error' " - "must be specified" + "must be given an argument" ) + for name in unspecified: + object.__setattr__(self, name, None) @implementer(IServiceCallReceivedEvent) diff --git a/Products/ZenHub/server/metrics.py b/Products/ZenHub/server/metrics.py index 6130722ced..761414e3a7 100644 --- a/Products/ZenHub/server/metrics.py +++ b/Products/ZenHub/server/metrics.py @@ -97,7 +97,8 @@ def decrementLegacyMetricCounters(event): global _legacy_worklist_counters for key in (event.priority, "total"): _legacy_worklist_counters[key] -= 1 - # If the count falls below zero, there's a bug and should be logged. + # If the count falls below zero, + # there's a bug and should be logged. if _legacy_worklist_counters[key] < 0: log.warn( "Counter is negative worklist=%s value=%s",