Skip to content

Commit 84248de

Browse files
davidmonterocrespo24David Montero
authored andcommitted
style(termination): fix pyink formatting for CI compliance
Collapse method signatures that fit within 80 chars and fix f-string literal in TokenUsageTermination.
1 parent 753e25e commit 84248de

File tree

7 files changed

+12
-35
lines changed

7 files changed

+12
-35
lines changed

src/google/adk/termination/external_termination.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ def set(self) -> None:
5555
"""Signals that the conversation should terminate at the next check."""
5656
self._terminated = True
5757

58-
async def check(
59-
self, events: Sequence[Event]
60-
) -> Optional[TerminationResult]:
58+
async def check(self, events: Sequence[Event]) -> Optional[TerminationResult]:
6159
if self._terminated:
6260
return TerminationResult(reason='Externally terminated')
6361
return None

src/google/adk/termination/function_call_termination.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ def __init__(self, function_name: str) -> None:
4343
def terminated(self) -> bool:
4444
return self._terminated
4545

46-
async def check(
47-
self, events: Sequence[Event]
48-
) -> Optional[TerminationResult]:
46+
async def check(self, events: Sequence[Event]) -> Optional[TerminationResult]:
4947
if self._terminated:
5048
return None
5149

src/google/adk/termination/max_iterations_termination.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ def __init__(self, max_iterations: int) -> None:
4444
def terminated(self) -> bool:
4545
return self._terminated
4646

47-
async def check(
48-
self, events: Sequence[Event]
49-
) -> Optional[TerminationResult]:
47+
async def check(self, events: Sequence[Event]) -> Optional[TerminationResult]:
5048
if self._terminated:
5149
return None
5250
self._count += len(events)

src/google/adk/termination/termination_condition.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ def terminated(self) -> bool:
5656
"""Whether this termination condition has been reached."""
5757

5858
@abc.abstractmethod
59-
async def check(
60-
self, events: Sequence[Event]
61-
) -> Optional[TerminationResult]:
59+
async def check(self, events: Sequence[Event]) -> Optional[TerminationResult]:
6260
"""Checks whether the termination condition is met.
6361
6462
Called after each event emitted by the agent. Returns a
@@ -117,9 +115,7 @@ def __init__(
117115
def terminated(self) -> bool:
118116
return self._terminated
119117

120-
async def check(
121-
self, events: Sequence[Event]
122-
) -> Optional[TerminationResult]:
118+
async def check(self, events: Sequence[Event]) -> Optional[TerminationResult]:
123119
if self._terminated:
124120
return None
125121
# Forward to both children so each accumulates its own state.
@@ -153,9 +149,7 @@ def __init__(
153149
def terminated(self) -> bool:
154150
return self._terminated
155151

156-
async def check(
157-
self, events: Sequence[Event]
158-
) -> Optional[TerminationResult]:
152+
async def check(self, events: Sequence[Event]) -> Optional[TerminationResult]:
159153
if self._terminated:
160154
return None
161155

src/google/adk/termination/text_mention_termination.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,17 @@ def __init__(
6060
def terminated(self) -> bool:
6161
return self._terminated
6262

63-
async def check(
64-
self, events: Sequence[Event]
65-
) -> Optional[TerminationResult]:
63+
async def check(self, events: Sequence[Event]) -> Optional[TerminationResult]:
6664
if self._terminated:
6765
return None
6866

6967
for event in events:
70-
if (
71-
self._sources
72-
and (event.author or '') not in self._sources
73-
):
68+
if self._sources and (event.author or '') not in self._sources:
7469
continue
7570

7671
if self._text in _stringify_event_content(event):
7772
self._terminated = True
78-
return TerminationResult(
79-
reason=f"Text '{self._text}' mentioned"
80-
)
73+
return TerminationResult(reason=f"Text '{self._text}' mentioned")
8174
return None
8275

8376
async def reset(self) -> None:

src/google/adk/termination/timeout_termination.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ def __init__(self, timeout_seconds: float) -> None:
4747
def terminated(self) -> bool:
4848
return self._terminated
4949

50-
async def check(
51-
self, events: Sequence[Event]
52-
) -> Optional[TerminationResult]:
50+
async def check(self, events: Sequence[Event]) -> Optional[TerminationResult]:
5351
if self._terminated:
5452
return None
5553

src/google/adk/termination/token_usage_termination.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ def __init__(
6969
def terminated(self) -> bool:
7070
return self._terminated
7171

72-
async def check(
73-
self, events: Sequence[Event]
74-
) -> Optional[TerminationResult]:
72+
async def check(self, events: Sequence[Event]) -> Optional[TerminationResult]:
7573
if self._terminated:
7674
return None
7775

@@ -116,7 +114,7 @@ async def check(
116114
self._terminated = True
117115
return TerminationResult(
118116
reason=(
119-
f'Token limit exceeded:'
117+
'Token limit exceeded:'
120118
f' completion_tokens={self._completion_tokens}'
121119
f' >= max_completion_tokens={self._max_completion_tokens}'
122120
)

0 commit comments

Comments
 (0)