codeant-ai-for-open-source[bot] commented on code in PR #38576: URL: https://github.com/apache/superset/pull/38576#discussion_r3482067525
########## tests/unit_tests/tasks/test_thumbnails.py: ########## @@ -0,0 +1,143 @@ +# 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 collections.abc import Callable, Iterator +from typing import Any +from unittest.mock import ANY, MagicMock, patch + +import pytest + + [email protected] +def mock_thumbnail_cache() -> Iterator[None]: + with patch("superset.tasks.thumbnails.thumbnail_cache", True): + yield Review Comment: **Suggestion:** Add a short docstring to this fixture function to describe that it enables thumbnail cache mocking for tests. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> This is a newly added Python fixture function and it has no docstring. The rule requires newly added Python functions and classes to include docstrings, so this is a real violation. </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=c7869893cb054541845ad8e386b5f5c2&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=c7869893cb054541845ad8e386b5f5c2&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/tasks/test_thumbnails.py **Line:** 25:28 **Comment:** *Custom Rule: Add a short docstring to this fixture function to describe that it enables thumbnail cache mocking for tests. 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%2F38576&comment_hash=79222a7219a28bebb6ae04c3056c52789ecb6eeaecdfd6e1da0251062ca80881&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38576&comment_hash=79222a7219a28bebb6ae04c3056c52789ecb6eeaecdfd6e1da0251062ca80881&reaction=dislike'>👎</a> ########## tests/unit_tests/utils/test_screenshot_cache_fix.py: ########## @@ -149,38 +153,37 @@ def test_cache_saved_only_when_image_generated( assert cached_value["status"] == "Updated" assert cached_value["image"] is not None - def test_no_intermediate_cache_during_computing( - self, mocker: MockerFixture, screenshot_obj, mock_user - ): - """Test that cache is not saved during COMPUTING state.""" + def test_computing_status_written_to_cache_early( + self, + mocker: MockerFixture, + screenshot_obj: BaseScreenshot, + mock_user: MagicMock, + ) -> None: + """compute_and_cache writes COMPUTING to cache before taking the screenshot + so concurrent tasks can detect it and avoid duplicate work.""" + mocker.patch(DISTRIBUTED_LOCK_PATH) mocker.patch(BASE_SCREENSHOT_PATH + ".get_from_cache_key", return_value=None) BaseScreenshot.cache = MockCache() - # Mock get_screenshot to check cache state during execution def check_cache_during_screenshot(*args, **kwargs): Review Comment: **Suggestion:** Add explicit type annotations for the inner helper function parameters and return type so the newly added function is fully typed. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> This is a newly added Python function in the changed test file, and it omits type hints for both parameters and return value. The custom rule requires new Python functions to be fully typed, so this is a real violation. </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=82a8244cd8f744cc86be588bfd3ad770&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=82a8244cd8f744cc86be588bfd3ad770&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/utils/test_screenshot_cache_fix.py **Line:** 168:168 **Comment:** *Custom Rule: Add explicit type annotations for the inner helper function parameters and return type so the newly added function is fully typed. 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%2F38576&comment_hash=135aa906b6bdb324011565834f68cd0528182fd1f7b3922bedee690898c94b59&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38576&comment_hash=135aa906b6bdb324011565834f68cd0528182fd1f7b3922bedee690898c94b59&reaction=dislike'>👎</a> ########## tests/unit_tests/tasks/test_thumbnails.py: ########## @@ -0,0 +1,143 @@ +# 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 collections.abc import Callable, Iterator +from typing import Any +from unittest.mock import ANY, MagicMock, patch + +import pytest + + [email protected] +def mock_thumbnail_cache() -> Iterator[None]: + with patch("superset.tasks.thumbnails.thumbnail_cache", True): + yield + + [email protected] +def mock_dashboard() -> MagicMock: + dashboard = MagicMock() + dashboard.id = 1 + dashboard.digest = "test_digest" + return dashboard Review Comment: **Suggestion:** Add a concise docstring to this fixture function explaining that it returns a mocked dashboard object with predefined attributes. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> This is also a newly added Python fixture function and it lacks a docstring. That directly violates the rule requiring new Python functions and classes to be documented inline. </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=3b9310bf72774959b4f4cc71b83d18ac&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=3b9310bf72774959b4f4cc71b83d18ac&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/tasks/test_thumbnails.py **Line:** 31:36 **Comment:** *Custom Rule: Add a concise docstring to this fixture function explaining that it returns a mocked dashboard object with predefined attributes. 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%2F38576&comment_hash=f5ddfa06f90feef68030e1a72aa737c981c73a8fdaca1adcfaf46ece598484d8&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38576&comment_hash=f5ddfa06f90feef68030e1a72aa737c981c73a8fdaca1adcfaf46ece598484d8&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]
