Dev-iL commented on code in PR #70101:
URL: https://github.com/apache/airflow/pull/70101#discussion_r3794559003


##########
providers/snowflake/src/airflow/providers/snowflake/hooks/snowflake_cortex_agent.py:
##########
@@ -159,11 +161,124 @@ def run_agent(
 
         endpoint = 
f"/api/v2/databases/{database}/schemas/{schema}/agents/{agent_name}:run"
 
-        return self._request(
-            method="POST",
-            endpoint=endpoint,
-            payload=payload,
-            timeout=timeout,
+        return cast(
+            "dict[str, Any]",
+            self._request(
+                method="POST",
+                endpoint=endpoint,
+                payload=payload,
+                timeout=timeout,
+            ),
+        )

Review Comment:
   Just to clarify, this is what I had in mind for the overloads:
   
   ```python
   from typing import Literal, overload
   
   # 1. Define the overload signature for "POST"
   @overload
   def make_request(method: Literal["POST"]) -> dict:
       ...
   
   # 2. Define the overload signature for "GET"
   @overload
   def make_request(method: Literal["GET"]) -> list[dict]:
       ...
   
   # 3. Define the implementation function
   def make_request(method: str) -> dict | list[dict]:
       if method == "POST":
           return {"status": "created"}
       elif method == "GET":
           return [{"status": "item1"}, {"status": "item2"}]
       else:
           raise ValueError(f"Unsupported method: {method}")
   
   # --- Usage Example ---
   
   # Type checker knows `res_post` is a `dict`
   res_post = make_request("POST")
   
   # Type checker knows `res_get` is a `list[dict]`
   res_get = make_request("GET")
   ```



-- 
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]

Reply via email to