bito-code-review[bot] commented on code in PR #36227:
URL: https://github.com/apache/superset/pull/36227#discussion_r2551880769


##########
superset/commands/report/execute.py:
##########
@@ -913,15 +984,19 @@ def run(self) -> None:
                 model=self._model,
             )
             user = security_manager.find_user(username)
+
+            start_time = datetime.utcnow()

Review Comment:
   
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Replace deprecated datetime.utcnow() calls</b></div>
   <div id="fix">
   
   The code uses `datetime.utcnow()`, which is deprecated in Python 3.12 and 
will be removed in future versions. This will cause deprecation warnings in 
production environments running Python 3.12+. Replace with 
`datetime.now(timezone.utc)` for timezone-aware UTC timestamps. The 
`AsyncExecuteReportScheduleCommand.run()` method calls 
`ReportScheduleStateMachine.run()` to execute reports, and this timing 
measurement is affected by the deprecated API usage.
   </div>
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ```
    -from datetime import datetime, timedelta
    +from datetime import datetime, timedelta, timezone
    @@ -988,1 +988,1 @@
    -            start_time = datetime.utcnow()
    +            start_time = datetime.now(timezone.utc)
    @@ -994,1 +994,1 @@
    -            elapsed_seconds = (datetime.utcnow() - 
start_time).total_seconds()
    +            elapsed_seconds = (datetime.now(timezone.utc) - 
start_time).total_seconds()
   ```
   
   </div>
   </details>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run <a 
href=https://github.com/apache/superset/pull/36227#issuecomment-3565422544>#07344b</a></i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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