codeant-ai-for-open-source[bot] commented on code in PR #37516:
URL: https://github.com/apache/superset/pull/37516#discussion_r3557409515
##########
superset/commands/chart/data/get_data_command.py:
##########
@@ -42,13 +43,23 @@ def run(self, **kwargs: Any) -> dict[str, Any]:
# (also evals `force` property)
cache_query_context = kwargs.get("cache", False)
force_cached = kwargs.get("force_cached", False)
+ defer_timing = kwargs.get("defer_timing", False)
Review Comment:
**Suggestion:** Add an explicit boolean type annotation to this newly
introduced local variable. [custom_rule]
**Severity Level:** Minor π§Ή
<details>
<summary><b>Why it matters? β </b></summary>
The rule requires type hints for newly introduced Python variables that can
be annotated. This local is newly added and inferred as a boolean, but it has
no explicit annotation, so the suggestion correctly identifies 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=34f3b8673d9e494b9536cd1593546f05&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=34f3b8673d9e494b9536cd1593546f05&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/commands/chart/data/get_data_command.py
**Line:** 46:46
**Comment:**
*Custom Rule: Add an explicit boolean type annotation to this newly
introduced local variable.
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%2F37516&comment_hash=0734d916118adb4d82e24c48d4930474d4852009a20b13e37cea99734351024c&reaction=like'>π</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=0734d916118adb4d82e24c48d4930474d4852009a20b13e37cea99734351024c&reaction=dislike'>π</a>
##########
superset/common/chart_data_timing.py:
##########
@@ -0,0 +1,102 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import logging
+import time
+from typing import Any
+
+from flask import current_app
+
+TIMING_KEY = "_chart_data_timing"
+TIMING_START_KEY = "_start_time"
+RESULT_PROCESSING_START_KEY = "_result_processing_start"
Review Comment:
**Suggestion:** Add explicit type annotations for the new module-level
timing constants so these variables are typed consistently with the type-hint
rule. [custom_rule]
**Severity Level:** Minor π§Ή
<details>
<summary><b>Why it matters? β </b></summary>
The file is new Python code and introduces module-level constants without
type annotations. Under the type-hint rule, these are annotatable variables and
should be explicitly typed.
</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=7f2591fdf96446dd9371d62afe13fab9&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=7f2591fdf96446dd9371d62afe13fab9&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/chart_data_timing.py
**Line:** 25:27
**Comment:**
*Custom Rule: Add explicit type annotations for the new module-level
timing constants so these variables are typed consistently with the type-hint
rule.
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%2F37516&comment_hash=c45b22e7cedeb132a249ec61a3572a00846cb8f893e41bdd46e87e30755c0416&reaction=like'>π</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=c45b22e7cedeb132a249ec61a3572a00846cb8f893e41bdd46e87e30755c0416&reaction=dislike'>π</a>
##########
superset/common/query_context_processor.py:
##########
@@ -83,11 +86,19 @@ def get_df_payload(
self, query_obj: QueryObject, force_cached: bool | None = False
) -> dict[str, Any]:
"""Handles caching around the df payload retrieval"""
+ t0 = time.perf_counter()
Review Comment:
**Suggestion:** Add an explicit type annotation for this timestamp variable
to satisfy the type-hint requirement for newly introduced variables.
[custom_rule]
**Severity Level:** Minor π§Ή
<details>
<summary><b>Why it matters? β </b></summary>
This newly added local variable is assigned a timestamp value without any
type annotation, which matches the Python type-hint rule for annotatable
variables.
</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=f5447579804c4858b6625b12d456b9eb&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=f5447579804c4858b6625b12d456b9eb&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_processor.py
**Line:** 89:89
**Comment:**
*Custom Rule: Add an explicit type annotation for this timestamp
variable to satisfy the type-hint requirement for newly introduced 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%2F37516&comment_hash=aa9d0097b7b591137ab4e1ea4c2ef13f33163d127e9ae0523cdbc00c6eecb05e&reaction=like'>π</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=aa9d0097b7b591137ab4e1ea4c2ef13f33163d127e9ae0523cdbc00c6eecb05e&reaction=dislike'>π</a>
##########
superset/commands/chart/data/get_data_command.py:
##########
@@ -42,13 +43,23 @@ def run(self, **kwargs: Any) -> dict[str, Any]:
# (also evals `force` property)
cache_query_context = kwargs.get("cache", False)
force_cached = kwargs.get("force_cached", False)
+ defer_timing = kwargs.get("defer_timing", False)
try:
payload = self._query_context.get_payload(
cache_query_context=cache_query_context,
force_cached=force_cached
)
except CacheLoadError as ex:
raise ChartDataCacheLoadError(ex.message) from ex
+ has_query_error = any(
+ query.get("error")
+ and self._query_context.result_type != ChartDataResultType.QUERY
+ for query in payload["queries"]
+ )
Review Comment:
**Suggestion:** Add an explicit boolean type annotation for this computed
local variable. [custom_rule]
**Severity Level:** Minor π§Ή
<details>
<summary><b>Why it matters? β </b></summary>
This is a newly introduced local variable whose value is a boolean
expression, and it is not annotated. That matches the stated type-hint rule
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=b4cc7b082c614499be7102fb7cd16887&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=b4cc7b082c614499be7102fb7cd16887&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/commands/chart/data/get_data_command.py
**Line:** 54:58
**Comment:**
*Custom Rule: Add an explicit boolean type annotation for this computed
local variable.
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%2F37516&comment_hash=8b8f4a981881050ba7a7b24a350a2e5ea2cbc5da06b7a92ef9447f6b8e4ef154&reaction=like'>π</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=8b8f4a981881050ba7a7b24a350a2e5ea2cbc5da06b7a92ef9447f6b8e4ef154&reaction=dislike'>π</a>
##########
superset/common/chart_data_timing.py:
##########
@@ -0,0 +1,102 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import logging
+import time
+from typing import Any
+
+from flask import current_app
+
+TIMING_KEY = "_chart_data_timing"
+TIMING_START_KEY = "_start_time"
+RESULT_PROCESSING_START_KEY = "_result_processing_start"
+
+logger = logging.getLogger(__name__)
Review Comment:
**Suggestion:** Annotate the module-level logger variable with its concrete
logger type to satisfy the type-hint requirement for relevant new variables.
[custom_rule]
**Severity Level:** Minor π§Ή
<details>
<summary><b>Why it matters? β </b></summary>
The new module-level `logger` variable is a relevant annotatable variable in
Python code, but it is left untyped. This matches the type-hint rule's
requirement for newly added variables that can be annotated.
</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=8d993c62a2a340b0be5a67a154cf1f7d&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=8d993c62a2a340b0be5a67a154cf1f7d&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/chart_data_timing.py
**Line:** 29:29
**Comment:**
*Custom Rule: Annotate the module-level logger variable with its
concrete logger type to satisfy the type-hint requirement for relevant new
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%2F37516&comment_hash=5e2ddffd3d1e5298ebe0f38c3dfa77c3164722bc873e7f2d07ea14b5f1fad1a2&reaction=like'>π</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=5e2ddffd3d1e5298ebe0f38c3dfa77c3164722bc873e7f2d07ea14b5f1fad1a2&reaction=dislike'>π</a>
##########
superset/common/query_context_processor.py:
##########
@@ -83,11 +86,19 @@ def get_df_payload(
self, query_obj: QueryObject, force_cached: bool | None = False
) -> dict[str, Any]:
"""Handles caching around the df payload retrieval"""
+ t0 = time.perf_counter()
+ timing: dict[str, Any] = {TIMING_START_KEY: t0}
+
+ # Phase: validate
+ t = time.perf_counter()
Review Comment:
**Suggestion:** Add an explicit type annotation to this newly added local
timing variable. [custom_rule]
**Severity Level:** Minor π§Ή
<details>
<summary><b>Why it matters? β </b></summary>
This is a newly introduced local timing variable and it lacks an explicit
type annotation, so it violates the stated type-hint requirement.
</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=86ef2cd1a30247aba1c4620b366193d5&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=86ef2cd1a30247aba1c4620b366193d5&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_processor.py
**Line:** 93:93
**Comment:**
*Custom Rule: Add an explicit type annotation to this newly added local
timing variable.
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%2F37516&comment_hash=1f74319f3318d199eb5826604cc4b5f9fc50850e0c81d1e0cd2a33e388acd986&reaction=like'>π</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=1f74319f3318d199eb5826604cc4b5f9fc50850e0c81d1e0cd2a33e388acd986&reaction=dislike'>π</a>
##########
superset/common/query_context_processor.py:
##########
@@ -109,8 +121,14 @@ def get_df_payload(
and len(query_obj.filter) > 0
):
cache.is_loaded = False
+ cache.is_cached = None
+ cache.cache_dttm = None
+ cache.cache_value = None
+ cache.queried_dttm = None
+ # Phase: db_execution (only on cache miss)
if query_obj and cache_key and not cache.is_loaded:
+ t = time.perf_counter()
Review Comment:
**Suggestion:** Add an explicit type annotation to this newly added local
timing variable. [custom_rule]
**Severity Level:** Minor π§Ή
<details>
<summary><b>Why it matters? β </b></summary>
This third timing local is newly introduced and remains untyped, so it fits
the custom ruleβs requirement to flag annotatable variables that omit type
hints.
</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=f67066fe55a4431ca06148013815a62d&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=f67066fe55a4431ca06148013815a62d&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_processor.py
**Line:** 131:131
**Comment:**
*Custom Rule: Add an explicit type annotation to this newly added local
timing variable.
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%2F37516&comment_hash=234b1dade342ab099e4cb0a3a357a3620e4f1210605181b1589cabc32fcb305e&reaction=like'>π</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=234b1dade342ab099e4cb0a3a357a3620e4f1210605181b1589cabc32fcb305e&reaction=dislike'>π</a>
##########
superset/common/query_context_processor.py:
##########
@@ -83,11 +86,19 @@ def get_df_payload(
self, query_obj: QueryObject, force_cached: bool | None = False
) -> dict[str, Any]:
"""Handles caching around the df payload retrieval"""
+ t0 = time.perf_counter()
+ timing: dict[str, Any] = {TIMING_START_KEY: t0}
+
+ # Phase: validate
+ t = time.perf_counter()
if query_obj:
# Always validate the query object before generating cache key
# This ensures sanitize_clause() is called and extras are
normalized
query_obj.validate()
+ timing["validate_ms"] = round((time.perf_counter() - t) * 1000, 2)
+ # Phase: cache_lookup
+ t = time.perf_counter()
Review Comment:
**Suggestion:** Add an explicit type annotation to this newly added local
timing variable. [custom_rule]
**Severity Level:** Minor π§Ή
<details>
<summary><b>Why it matters? β </b></summary>
This second newly added timing local is also unannotated, and the rule
applies equally to relevant variables introduced in modified Python 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=74750a3e8c214912bee1be83ae666915&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=74750a3e8c214912bee1be83ae666915&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_processor.py
**Line:** 101:101
**Comment:**
*Custom Rule: Add an explicit type annotation to this newly added local
timing variable.
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%2F37516&comment_hash=9b91fa9ffdf89c990713851824433d95ea8e9b62478601557a61f5961ec5f5b0&reaction=like'>π</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=9b91fa9ffdf89c990713851824433d95ea8e9b62478601557a61f5961ec5f5b0&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]