rusackas commented on code in PR #41502:
URL: https://github.com/apache/superset/pull/41502#discussion_r3598458630


##########
superset/utils/cache.py:
##########
@@ -73,7 +73,7 @@ def set_and_log_cache(
     if timeout == CACHE_DISABLED_TIMEOUT:
         return
     try:
-        dttm = datetime.utcnow().isoformat().split(".")[0]
+        dttm = 
datetime.now(timezone.utc).replace(tzinfo=None).isoformat().split(".")[0]
         value = {**cache_value, "dttm": dttm}

Review Comment:
   Added the `str` annotation there, thanks.



##########
superset/commands/report/execute.py:
##########
@@ -569,22 +571,28 @@ def _get_screenshots(self) -> list[bytes]:
                         "Screenshot failed; aborting to avoid sending a 
partial report"
                     )
                 imges.append(imge)
-            elapsed_seconds = (datetime.utcnow() - start_time).total_seconds()
+            elapsed_seconds = (
+                datetime.now(timezone.utc).replace(tzinfo=None) - start_time
+            ).total_seconds()

Review Comment:
   Added the `float` annotation, thanks.



##########
superset/commands/report/execute.py:
##########
@@ -569,22 +571,28 @@ def _get_screenshots(self) -> list[bytes]:
                         "Screenshot failed; aborting to avoid sending a 
partial report"
                     )
                 imges.append(imge)
-            elapsed_seconds = (datetime.utcnow() - start_time).total_seconds()
+            elapsed_seconds = (
+                datetime.now(timezone.utc).replace(tzinfo=None) - start_time
+            ).total_seconds()
             logger.info(
                 "Screenshot capture took %.2fs - execution_id: %s",
                 elapsed_seconds,
                 self._execution_id,
             )
         except SoftTimeLimitExceeded as ex:
-            elapsed_seconds = (datetime.utcnow() - start_time).total_seconds()
+            elapsed_seconds = (
+                datetime.now(timezone.utc).replace(tzinfo=None) - start_time
+            ).total_seconds()

Review Comment:
   This one reassigns the same `elapsed_seconds` already annotated a few lines 
up in the try block, so mypy flags a redefinition if I annotate it again here. 
Left it as-is, it inherits the type.



##########
superset/commands/report/execute.py:
##########
@@ -759,7 +767,9 @@ def _get_data(self, result_format: ChartDataResultFormat) 
-> bytes:
                     request_payload=request_payload,
                     timeout=app.config["ALERT_REPORTS_CSV_REQUEST_TIMEOUT"],
                 )
-            elapsed_seconds = (datetime.utcnow() - start_time).total_seconds()
+            elapsed_seconds = (
+                datetime.now(timezone.utc).replace(tzinfo=None) - start_time
+            ).total_seconds()

Review Comment:
   Added the `float` annotation, thanks.



##########
superset/commands/report/execute.py:
##########
@@ -810,7 +824,9 @@ def _get_embedded_data(self) -> pd.DataFrame:
                 auth_cookies,
                 timeout=app.config["ALERT_REPORTS_CSV_REQUEST_TIMEOUT"],
             )
-            elapsed_seconds = (datetime.utcnow() - start_time).total_seconds()
+            elapsed_seconds = (
+                datetime.now(timezone.utc).replace(tzinfo=None) - start_time
+            ).total_seconds()

Review Comment:
   Added the `float` annotation, thanks.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to