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


##########
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:
   Yeah, what Jed said.  That was to make MyPy happy due to the underlying 
typing for `_start_time`.  Thanks for fixing that, I should have questioned it 
instead of just rolling with it.



-- 
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