codeant-ai-for-open-source[bot] commented on code in PR #40084:
URL: https://github.com/apache/superset/pull/40084#discussion_r3533034457


##########
tests/unit_tests/extensions/test_cache_middleware.py:
##########
@@ -64,6 +64,21 @@ def test_asset_path_is_intercepted() -> None:
     assert "Cookie" not in vary
 
 
+def test_nested_asset_path_is_intercepted() -> None:
+    headers = call_middleware(
+        "/api/v1/extensions/acme/my-ext/workers/nested/chunk.wasm",
+        [("Vary", "Accept-Encoding, Cookie")],
+    )

Review Comment:
   **Suggestion:** Add an explicit type annotation to this local headers 
collection variable to comply with the type-hint requirement for relevant 
variables. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The new local variable `headers` is assigned a value with a clear, known 
type (`ResponseHeaders`), but it is not explicitly annotated. This matches the 
type-hint rule for relevant variables in newly added Python code.
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=1547d00962974084ac153acc7e9e3c72&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=1547d00962974084ac153acc7e9e3c72&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/extensions/test_cache_middleware.py
   **Line:** 67:71
   **Comment:**
        *Custom Rule: Add an explicit type annotation to this local headers 
collection variable to comply with 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%2F40084&comment_hash=4feb48a2258220778b2aa9c50f970d12c7f2cbdebc89792a05bb44a803ccd4cd&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40084&comment_hash=4feb48a2258220778b2aa9c50f970d12c7f2cbdebc89792a05bb44a803ccd4cd&reaction=dislike'>👎</a>



##########
tests/unit_tests/extensions/test_cache_middleware.py:
##########
@@ -64,6 +64,21 @@ def test_asset_path_is_intercepted() -> None:
     assert "Cookie" not in vary
 
 
+def test_nested_asset_path_is_intercepted() -> None:
+    headers = call_middleware(
+        "/api/v1/extensions/acme/my-ext/workers/nested/chunk.wasm",
+        [("Vary", "Accept-Encoding, Cookie")],
+    )
+    vary = dict(headers).get("Vary", "")
+    assert "Cookie" not in vary
+
+
+def test_get_endpoint_with_trailing_slash_is_not_intercepted() -> None:
+    upstream = [("Vary", "Accept-Encoding, Cookie")]

Review Comment:
   **Suggestion:** Annotate this local upstream headers variable with the 
shared response-headers alias to satisfy the type-hint rule for relevant 
variables. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The newly added local variable `upstream` is also unannotated, despite 
having a clearly inferable list-of-tuples type that could be annotated with the 
existing `ResponseHeaders` alias. This is a valid type-hint violation.
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=7dc1ec4b77f94c0d895449c6fab2580e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=7dc1ec4b77f94c0d895449c6fab2580e&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/extensions/test_cache_middleware.py
   **Line:** 77:77
   **Comment:**
        *Custom Rule: Annotate this local upstream headers variable with the 
shared response-headers alias to satisfy the type-hint rule 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%2F40084&comment_hash=38d6d31a5fa34f02954cb879340576186852f1b78a62a95a7ab66b9fac6e2023&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40084&comment_hash=38d6d31a5fa34f02954cb879340576186852f1b78a62a95a7ab66b9fac6e2023&reaction=dislike'>👎</a>



##########
tests/unit_tests/extensions/test_cache_middleware.py:
##########
@@ -64,6 +64,21 @@ def test_asset_path_is_intercepted() -> None:
     assert "Cookie" not in vary
 
 
+def test_nested_asset_path_is_intercepted() -> None:
+    headers = call_middleware(
+        "/api/v1/extensions/acme/my-ext/workers/nested/chunk.wasm",
+        [("Vary", "Accept-Encoding, Cookie")],
+    )
+    vary = dict(headers).get("Vary", "")

Review Comment:
   **Suggestion:** Add a `str` type annotation to this derived local variable 
so the new test code remains fully type-annotated. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The local variable `vary` is introduced without an explicit type annotation, 
even though it is a straightforward `str` value derived from the headers. This 
is a real omission under the Python type-hint rule.
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=368fe5a3bc2240649cfc913e300ecd7a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=368fe5a3bc2240649cfc913e300ecd7a&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/extensions/test_cache_middleware.py
   **Line:** 72:72
   **Comment:**
        *Custom Rule: Add a `str` type annotation to this derived local 
variable so the new test code remains fully type-annotated.
   
   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%2F40084&comment_hash=2ff5ddd26a01cf5e5696b677c22c6aa5b76982031242189fd3e6db7a73c7191d&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40084&comment_hash=2ff5ddd26a01cf5e5696b677c22c6aa5b76982031242189fd3e6db7a73c7191d&reaction=dislike'>👎</a>



##########
tests/unit_tests/extensions/test_local_extensions_watcher.py:
##########
@@ -0,0 +1,55 @@
+# 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 typing import Any
+
+from watchdog.events import FileDeletedEvent, FileMovedEvent
+
+from superset.extensions.local_extensions_watcher import 
_get_file_handler_class
+
+
+def make_handler() -> Any:
+    handler_class = _get_file_handler_class()
+    handler = handler_class()
+    # Avoid spinning up real debounce timers in unit tests.
+    handler._schedule_reload = lambda _path: None

Review Comment:
   **Suggestion:** Replace the untyped inline lambda with a typed callable (or 
explicitly annotate the callable assignment) so the function parameter type is 
not omitted. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The new code assigns an untyped lambda to a callable used in Python code. 
Under the type-hints rule, this is a modified Python construct that omits 
annotating the callable or its parameter, so the suggestion correctly 
identifies a real violation.
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=8ae71c4778cd4f22b1d448e2061c1119&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=8ae71c4778cd4f22b1d448e2061c1119&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/extensions/test_local_extensions_watcher.py
   **Line:** 28:28
   **Comment:**
        *Custom Rule: Replace the untyped inline lambda with a typed callable 
(or explicitly annotate the callable assignment) so the function parameter type 
is not omitted.
   
   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%2F40084&comment_hash=dd59ae79d986204289b7977c2dbf2afbbfa34c61af549c75930e610e158be4d2&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40084&comment_hash=dd59ae79d986204289b7977c2dbf2afbbfa34c61af549c75930e610e158be4d2&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]

Reply via email to