kaxil commented on code in PR #71461:
URL: https://github.com/apache/airflow/pull/71461#discussion_r3774122453


##########
providers/anthropic/src/airflow/providers/anthropic/hooks/anthropic.py:
##########
@@ -587,13 +604,24 @@ def _latest_idle_reason(self, session_id: str, 
kickoff_event_id: str | None) ->
 
     def poll_session_completion(
         self, session_id: str, *, expect_outcome: bool = False, 
kickoff_event_id: str | None = None
-    ) -> tuple[bool, str | None]:
+    ) -> tuple[bool, str | None, str | None]:

Review Comment:
   Added `SessionPollResult(done, error_message, stop_reason)`.
   
   One thing worth reporting, because it changed how much of the change was 
needed: the annotation on its own does not buy the protection. mypy accepts a 
transposed unpack of the old signature silently --
   
   ```python
   done, stop_reason, error_message = hook.poll_session_completion(...)
   ```
   
   -- since both slots are `str | None`, and it accepts the same positional 
unpack of a NamedTuple just as quietly.
   
   So the guard is the NamedTuple *plus* dropping positional unpacking at the 
consumers. `wait_for_session` and the trigger's `run` now hold the result and 
read `poll.done` / `poll.error_message` / `poll.stop_reason`; that mypy does 
check, a wrong field name being an `attr-defined` error. The returns inside the 
hook use keywords for the same reason, and the tests follow, so a mocked poll 
result now names its fields instead of being a bare triple.
   
   `evaluate_session_state` stays a plain tuple: its second and third elements 
are `str | None` and `bool`, and mypy does reject a transposed unpack there 
(`Argument 1 ... has incompatible type "bool"; expected "str | None"`). Happy 
to convert it too for uniformity, but the failure you spotted is specific to 
the two same-typed slots.



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