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


##########
superset/db_engine_specs/aws_iam.py:
##########
@@ -54,9 +53,14 @@
 # Cache STS credentials: key = (role_arn, region, external_id), TTL = 10 min
 # Using a TTL shorter than the minimum supported session duration (900s) avoids
 # reusing expired STS credentials when a short session_duration is configured.
-_credentials_cache: TTLCache[tuple[str, str, str | None], dict[str, Any]] = 
TTLCache(
-    maxsize=100, ttl=600
-)
+try:
+    from cachetools import TTLCache
+
+    _credentials_cache: MutableMapping[
+        tuple[str, str, str | None], dict[str, Any]
+    ] = TTLCache(maxsize=100, ttl=600)
+except ImportError:
+    _credentials_cache = {}

Review Comment:
   **Suggestion:** Add an explicit type annotation to the fallback cache 
assignment so the variable remains typed even when the optional dependency 
import fails. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   The module annotates `_credentials_cache` in the successful import branch, 
but the fallback branch assigns an untyped empty dict. This violates the Python 
type-hint rule for newly modified code because the variable loses its explicit 
annotation when `cachetools` is unavailable.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </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=8e3f6ca037ed4482904b050dbe6f761a&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=8e3f6ca037ed4482904b050dbe6f761a&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/db_engine_specs/aws_iam.py
   **Line:** 63:63
   **Comment:**
        *Custom Rule: Add an explicit type annotation to the fallback cache 
assignment so the variable remains typed even when the optional dependency 
import fails.
   
   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%2F38269&comment_hash=86a8d4e0c9a12555ea40f35aef4dafbb492c3b76f537ad82b66fbfd9ec1cce3c&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38269&comment_hash=86a8d4e0c9a12555ea40f35aef4dafbb492c3b76f537ad82b66fbfd9ec1cce3c&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