bito-code-review[bot] commented on code in PR #39782:
URL: https://github.com/apache/superset/pull/39782#discussion_r3243684789
##########
superset/models/helpers.py:
##########
@@ -2394,7 +2394,15 @@ def dttm_sql_literal(self, dttm: datetime, col:
"TableColumn") -> str:
if tf:
if tf in {"epoch_ms", "epoch_s"}:
- seconds_since_epoch = int(dttm.timestamp())
+ # In general, Superset works with timezone-naive datetime
objects
+ # internally. However, timestamp() applies local timezone to
+ # timezone-naive datetime objects. Therefore, we have to be
explicit
+ # about UTC before calling timestamp().
+ dttm_tz_aware = dttm
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Assert statement used in production code</b></div>
<div id="fix">
Replace the `assert` statement on line 2401 with a proper exception raise.
Assertions can be disabled with Python's `-O` flag and should not be used for
runtime validation in production code.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
if dttm.tzinfo is not None:
raise ValueError("datetime object is not timezone-naive")
````
</div>
</details>
</div>
<div><details><summary><b>Review Rule</b></summary><div>Bito created the
rule <strong><code>Do Not Use Assert for Production Runtime
Validation</code></strong> for <strong>repo:</strong>
<code>apache/superset</code>, <strong>language:</strong> <code>Python</code>.
Bito will avoid suggestions that match this rule. You can manage review rules
<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>here</a>.</div></details></div>
<small><i>Code Review Run #354d9b</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]