jedcunningham commented on code in PR #30024:
URL: https://github.com/apache/airflow/pull/30024#discussion_r1160948144


##########
airflow/stats.py:
##########
@@ -159,35 +163,37 @@ class Timer(TimerProtocol):
     _start_time: int | None
     duration: int | None
 
-    def __init__(self, real_timer=None):
+    def __init__(self, real_timer: Timer | None = None) -> None:
         self.real_timer = real_timer
 
-    def __enter__(self):
+    def __enter__(self) -> Timer:
         return self.start()
 
-    def __exit__(self, exc_type, exc_value, traceback):
+    def __exit__(self, exc_type, exc_value, traceback) -> None:
         self.stop()
 
-    def start(self):
+    def start(self) -> Timer:
         """Start the timer."""
         if self.real_timer:
             self.real_timer.start()
-        self._start_time = time.perf_counter()
+        self._start_time = int(time.perf_counter())
         return self
 
-    def stop(self, send=True):
+    def stop(self, send: bool = True) -> None:
         """Stop the timer, and optionally send it to stats backend."""
-        self.duration = time.perf_counter() - self._start_time
+        self.duration = int(time.perf_counter()) - (self._start_time or 0)

Review Comment:
   I assume it wasn't intentional, and was driven by the fact `_start_time` was 
originally typed as int. #30532 changes it back.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to