bito-code-review[bot] commented on code in PR #38977:
URL: https://github.com/apache/superset/pull/38977#discussion_r3016903361
##########
superset/mcp_service/dashboard/schemas.py:
##########
@@ -515,6 +516,13 @@ def dashboard_serializer(dashboard: "Dashboard") ->
DashboardInfo:
)
+def _humanize_timestamp(dt: datetime | None) -> str | None:
+ """Convert a datetime to a humanized string like '2 hours ago'."""
+ if dt is None:
+ return None
+ return humanize.naturaltime(datetime.now() - dt)
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>datetime.now() called without timezone argument</b></div>
<div id="fix">
Add timezone argument to `datetime.now()` call. Use
`datetime.now(timezone.utc)` or `datetime.now(tz=timezone.utc)` for
timezone-aware datetime.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
-from datetime import datetime
+from datetime import datetime, timezone
@@ -523,1 +523,1 @@
- return humanize.naturaltime(datetime.now() - dt)
+ return humanize.naturaltime(datetime.now(timezone.utc) - dt)
```
</div>
</details>
</div>
<small><i>Code Review Run #7617a5</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]