This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch v3-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-3-test by this push:
new ef95d554081 Fix mypy failure on datadog timer wrapped by shared
observability Timer (#69202) (#70887)
ef95d554081 is described below
commit ef95d5540811bf7b86dae7fc21747ca4a26b637d
Author: Jarek Potiuk <[email protected]>
AuthorDate: Sat Aug 1 03:56:39 2026 +0200
Fix mypy failure on datadog timer wrapped by shared observability Timer
(#69202) (#70887)
The real_timer parameter accepts any backend timer exposing start/stop
(pystatsd, dogstatsd), not the shared Timer itself. Typing it against a
minimal protocol reflects that contract and stops mypy rejecting the
typed dogstatsd TimedContextManagerDecorator.
(cherry picked from commit 594604681b2f0a4d2da66d32f13acbd6e2262850)
Co-authored-by: Wei Lee <[email protected]>
---
.../src/airflow_shared/observability/metrics/protocols.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git
a/shared/observability/src/airflow_shared/observability/metrics/protocols.py
b/shared/observability/src/airflow_shared/observability/metrics/protocols.py
index 5e4c76434e2..fad6e6a570b 100644
--- a/shared/observability/src/airflow_shared/observability/metrics/protocols.py
+++ b/shared/observability/src/airflow_shared/observability/metrics/protocols.py
@@ -27,6 +27,14 @@ if TYPE_CHECKING:
DeltaType = int | float | datetime.timedelta
+class BackendTimerProtocol(Protocol):
+ """Minimal interface of a backend timer (e.g. pystatsd / dogstatsd)
wrapped by :class:`Timer`."""
+
+ def start(self) -> object: ...
+
+ def stop(self) -> object: ...
+
+
class TimerProtocol(Protocol):
"""Type protocol for StatsLogger.timer."""
@@ -100,7 +108,7 @@ class Timer(TimerProtocol):
_start_time: float | None
duration: float | None
- def __init__(self, real_timer: Timer | None = None) -> None:
+ def __init__(self, real_timer: BackendTimerProtocol | None = None) -> None:
self.real_timer = real_timer
def __enter__(self) -> Self: