@@ -217,7 +217,7 @@ def message_dicts(self) -> list[MessageDict]:
217217 """
218218 return [
219219 t .cast (
220- MessageDict ,
220+ " MessageDict" ,
221221 m .model_dump (include = {"role" , "content_parts" }, exclude_none = True ),
222222 )
223223 for m in self .all
@@ -409,7 +409,7 @@ def inject_tool_prompt(
409409
410410 tool_system_prompt = tool_description_prompt_part (
411411 definitions ,
412- t .cast (t .Literal [" xml" , " json-in-xml" ] , mode ),
412+ t .cast (" t.Literal[' xml', ' json-in-xml']" , mode ),
413413 )
414414 return self .inject_system_content (tool_system_prompt )
415415
@@ -524,8 +524,7 @@ def __call__(
524524 self ,
525525 chat : Chat ,
526526 / ,
527- ) -> t .Awaitable [Chat | None ]:
528- ...
527+ ) -> t .Awaitable [Chat | None ]: ...
529528
530529
531530@runtime_checkable
@@ -534,8 +533,7 @@ def __call__(
534533 self ,
535534 chat : Chat ,
536535 / ,
537- ) -> "PipelineStepGenerator | PipelineStepContextManager | t.Awaitable[PipelineStepGenerator | PipelineStepContextManager | None]" :
538- ...
536+ ) -> "PipelineStepGenerator | PipelineStepContextManager | t.Awaitable[PipelineStepGenerator | PipelineStepContextManager | None]" : ...
539537
540538
541539ThenChatCallback = _ThenChatCallback | _ThenChatStepCallback
@@ -550,8 +548,7 @@ def __call__(
550548 self ,
551549 chats : list [Chat ],
552550 / ,
553- ) -> t .Awaitable [list [Chat ]]:
554- ...
551+ ) -> t .Awaitable [list [Chat ]]: ...
555552
556553
557554@runtime_checkable
@@ -560,8 +557,7 @@ def __call__(
560557 self ,
561558 chats : list [Chat ],
562559 / ,
563- ) -> "PipelineStepGenerator | PipelineStepContextManager | t.Awaitable[PipelineStepGenerator | PipelineStepContextManager]" :
564- ...
560+ ) -> "PipelineStepGenerator | PipelineStepContextManager | t.Awaitable[PipelineStepGenerator | PipelineStepContextManager]" : ...
565561
566562
567563MapChatCallback = _MapChatCallback | _MapChatStepCallback
@@ -658,9 +654,10 @@ def depth(self) -> int:
658654 This is useful for setting constraints on recursion depth.
659655 """
660656 depth = 0
661- while self .parent is not None :
657+ current = self
658+ while current .parent is not None :
662659 depth += 1
663- self = self .parent
660+ current = current .parent
664661 return depth
665662
666663
@@ -852,8 +849,7 @@ def add(
852849 and self .chat .all [- 1 ].role == message_list [0 ].role
853850 and (
854851 merge_strategy == "all"
855- or merge_strategy == "only-user-role"
856- and self .chat .all [- 1 ].role == "user"
852+ or (merge_strategy == "only-user-role" and self .chat .all [- 1 ].role == "user" )
857853 )
858854 ):
859855 self .chat .all [- 1 ].content_parts += message_list [0 ].content_parts
@@ -1263,7 +1259,7 @@ async def _then_tools(self, chat: Chat) -> PipelineStepContextManager | None:
12631259
12641260 # Parse the actual tool calls
12651261
1266- tool_calls : ( list [ApiToolCall ] | list [XmlToolCall ] | list [JsonInXmlToolCall ] | None ) = None
1262+ tool_calls : list [ApiToolCall ] | list [XmlToolCall ] | list [JsonInXmlToolCall ] | None = None
12671263 if self .tool_mode == "api" :
12681264 tool_calls = chat .last .tool_calls
12691265 if self .tool_mode == "xml" :
@@ -1435,7 +1431,7 @@ async def complete() -> None:
14351431 )
14361432
14371433 generator = t .cast (
1438- PipelineStepGenerator ,
1434+ " PipelineStepGenerator" ,
14391435 await exit_stack .enter_async_context (aclosing (result )),
14401436 )
14411437 async for step in generator :
@@ -1675,7 +1671,7 @@ async def _step( # noqa: PLR0915, PLR0912
16751671
16761672 if inspect .isasyncgen (chats_or_generator ):
16771673 generator = t .cast (
1678- PipelineStepGenerator ,
1674+ " PipelineStepGenerator" ,
16791675 await exit_stack .enter_async_context (
16801676 aclosing (chats_or_generator ),
16811677 ),
0 commit comments