This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 594604681b2 Fix mypy failure on datadog timer wrapped by shared 
observability Timer (#69202)
594604681b2 is described below

commit 594604681b2f0a4d2da66d32f13acbd6e2262850
Author: Wei Lee <[email protected]>
AuthorDate: Wed Jul 1 20:07:14 2026 +0800

    Fix mypy failure on datadog timer wrapped by shared observability Timer 
(#69202)
    
    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.
---
 .../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:

Reply via email to