codeant-ai-for-open-source[bot] commented on code in PR #41425:
URL: https://github.com/apache/superset/pull/41425#discussion_r3525486090
##########
tests/integration_tests/core_tests.py:
##########
@@ -899,6 +899,23 @@ def test_explore_redirect(self, mock_command: mock.Mock):
rv =
self.client.get(f"/explore/?form_data={quote(json.dumps(form_data))}")
assert rv.headers["Location"] ==
f"/explore/?form_data_key={random_key}"
+ @pytest.mark.usefixtures("load_energy_table_with_slice")
+ @mock.patch("superset.security.SupersetSecurityManager.raise_for_access")
+ def test_explore_view_checks_datasource_access(
+ self, mock_raise_for_access: mock.Mock
+ ) -> None:
+ """The explore view runs the per-datasource access check on the loaded
+ datasource, consistent with the explore command, before rendering its
+ metadata."""
+ self.login(ADMIN_USERNAME)
+ tbl_id = self.table_ids.get("energy_usage")
Review Comment:
**Suggestion:** Add an explicit type annotation for this local variable so
its optional integer type is clear and consistent with the type-hinting rule.
[custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This is newly added Python code, and `tbl_id` is a variable whose type can
be annotated (it is an optional integer from `dict.get`). The rule requires
type hints on relevant variables that can be annotated, so the omission is a
real violation.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=6070193d36f44e07af089267a16c1e66&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=6070193d36f44e07af089267a16c1e66&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/integration_tests/core_tests.py
**Line:** 911:911
**Comment:**
*Custom Rule: Add an explicit type annotation for this local variable
so its optional integer type is clear and consistent with the type-hinting 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%2F41425&comment_hash=393dfa9be149fa95c209e591721b94b72abac5a671cff3ad780c2b6ce5bfd8e4&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41425&comment_hash=393dfa9be149fa95c209e591721b94b72abac5a671cff3ad780c2b6ce5bfd8e4&reaction=dislike'>👎</a>
##########
tests/integration_tests/core_tests.py:
##########
@@ -899,6 +899,23 @@ def test_explore_redirect(self, mock_command: mock.Mock):
rv =
self.client.get(f"/explore/?form_data={quote(json.dumps(form_data))}")
assert rv.headers["Location"] ==
f"/explore/?form_data_key={random_key}"
+ @pytest.mark.usefixtures("load_energy_table_with_slice")
+ @mock.patch("superset.security.SupersetSecurityManager.raise_for_access")
+ def test_explore_view_checks_datasource_access(
+ self, mock_raise_for_access: mock.Mock
+ ) -> None:
+ """The explore view runs the per-datasource access check on the loaded
+ datasource, consistent with the explore command, before rendering its
+ metadata."""
+ self.login(ADMIN_USERNAME)
+ tbl_id = self.table_ids.get("energy_usage")
+
+ self.client.post(f"/explore/table/{tbl_id}/")
+
+ mock_raise_for_access.assert_called_once()
+ _, kwargs = mock_raise_for_access.call_args
Review Comment:
**Suggestion:** Add a concrete type annotation for the extracted call
arguments mapping to satisfy required typing for relevant newly added
variables. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This unpacking introduces a new local variable `kwargs` in Python code
without a type hint. Since the rule covers relevant variables that can be
annotated, this omission matches the stated violation.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=516db0829ae34720be209eb1f8a63c4e&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=516db0829ae34720be209eb1f8a63c4e&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/integration_tests/core_tests.py
**Line:** 916:916
**Comment:**
*Custom Rule: Add a concrete type annotation for the extracted call
arguments mapping to satisfy required typing for relevant newly added 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%2F41425&comment_hash=d1acbed18247de249511b5bae3aba67e920781130e8ba62531cfbb9c35e5a728&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41425&comment_hash=d1acbed18247de249511b5bae3aba67e920781130e8ba62531cfbb9c35e5a728&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]