codeant-ai-for-open-source[bot] commented on code in PR #42052:
URL: https://github.com/apache/superset/pull/42052#discussion_r3588799543
##########
superset/common/query_context_factory.py:
##########
@@ -245,6 +245,20 @@ def _apply_granularity( # noqa: C901
}
x_axis = form_data and form_data.get("x_axis")
+ should_infer_filter_granularity = (
+ is_adhoc_column(x_axis) # type: ignore
+ and query_object.granularity is None
+ and bool(query_object.from_dttm or query_object.to_dttm)
+ and (main_dttm_col := getattr(datasource, "main_dttm_col", None))
+ in temporal_columns
+ )
Review Comment:
**Suggestion:** Add an explicit type annotation for this newly introduced
boolean variable to satisfy the type-hint requirement for relevant variables.
[custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
This newly introduced Python variable is a relevant local variable that can
be annotated, but it has no explicit type hint. The custom rule requires type
hints on new or modified Python code where annotations are applicable, so this
is a real violation.
</details>
<details>
<summary><b>Rule source ๐ </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=a694ab3a0fdc49c785f7fa5f10ce2998&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=a694ab3a0fdc49c785f7fa5f10ce2998&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/common/query_context_factory.py
**Line:** 248:254
**Comment:**
*Custom Rule: Add an explicit type annotation for this newly introduced
boolean variable to satisfy the type-hint requirement for relevant variables.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42052&comment_hash=0253060aee829a6893997df8e2a9b19e3b170cc6285872f7c148fbbc7ea6ce4b&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42052&comment_hash=0253060aee829a6893997df8e2a9b19e3b170cc6285872f7c148fbbc7ea6ce4b&reaction=dislike'>๐</a>
##########
tests/unit_tests/common/test_query_context_factory.py:
##########
@@ -384,6 +387,94 @@ def test_apply_granularity_no_granularity(self):
assert query_object.columns == ["ds", "other_col"]
+ def
test_apply_granularity_uses_main_datetime_for_bounded_expression_axis(self):
Review Comment:
**Suggestion:** Add type hints to this new test method signature, including
an explicit return type annotation. [custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
This is a new Python test method without type annotations on the function
signature, so it matches the rule requiring type hints on new or modified
Python functions/methods.
</details>
<details>
<summary><b>Rule source ๐ </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=638cf7eafca24c69bda7dc9ccfcf0693&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=638cf7eafca24c69bda7dc9ccfcf0693&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/unit_tests/common/test_query_context_factory.py
**Line:** 390:390
**Comment:**
*Custom Rule: Add type hints to this new test method signature,
including an explicit return type annotation.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42052&comment_hash=e0d5e49989b323d0703df6e13bb4a439d7fb5062bd328002ef6db59bb2ddca72&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42052&comment_hash=e0d5e49989b323d0703df6e13bb4a439d7fb5062bd328002ef6db59bb2ddca72&reaction=dislike'>๐</a>
##########
tests/unit_tests/models/test_no_filter_time_range.py:
##########
@@ -208,6 +210,43 @@ def test_actual_from_to_dttm_produces_time_filter(
)
+def test_time_range_without_granularity_filters_main_datetime_column(
+ mocker: MockerFixture,
+ app: Flask,
+) -> None:
+ """A SQL-expression dimension must not cause a dashboard range to be
dropped."""
+ dataset = _make_dataset(mocker)
+ expression: AdhocColumn = {
+ "sqlExpression": "value / 10",
+ "label": "value_bucket",
+ "columnType": "BASE_AXIS",
+ }
+ query_object = QueryObject(
+ granularity=None,
+ is_timeseries=False,
+ metrics=["count"],
+ columns=[expression],
+ from_dttm=datetime(2024, 1, 1, tzinfo=timezone.utc),
+ to_dttm=datetime(2024, 1, 31, tzinfo=timezone.utc),
+ )
Review Comment:
**Suggestion:** Add an explicit type annotation for this newly introduced
local object to satisfy the requirement for annotating relevant variables.
[custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
The new local variable `query_object` is introduced without an explicit type
annotation even though it is a central, annotatable variable in newly added
Python code. This matches the rule requiring type hints on relevant variables
in modified code.
</details>
<details>
<summary><b>Rule source ๐ </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=172b95ad87f1416b82784d5f37b60345&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=172b95ad87f1416b82784d5f37b60345&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/unit_tests/models/test_no_filter_time_range.py
**Line:** 219:231
**Comment:**
*Custom Rule: Add an explicit type annotation for this newly introduced
local object to satisfy the requirement for annotating relevant variables.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42052&comment_hash=6a1e83d08b298d585293bd064b3cdad5d92223828196a7dc6cbe8989f5b2e707&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42052&comment_hash=6a1e83d08b298d585293bd064b3cdad5d92223828196a7dc6cbe8989f5b2e707&reaction=dislike'>๐</a>
--
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]