Skip to content

Commit 5e4867e

Browse files
committed
fix(sessions): address CI feedback (formatting and imports)
- Added \ rom __future__ import annotations\ to address forward-reference type failures in session_data_transformer.py. - Applied \pyink\ and \isort\ formatting across the repo to resolve Pyink check failures.
1 parent 9e0374b commit 5e4867e

16 files changed

Lines changed: 124 additions & 135 deletions

File tree

contributing/samples/human_in_loop/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ async def call_agent(query: str):
113113
updated_tool_output_data = {
114114
"status": "approved",
115115
"ticketId": ticket_id,
116-
"approver_feedback": (
117-
"Approved by manager at " + str(asyncio.get_event_loop().time())
116+
"approver_feedback": "Approved by manager at " + str(
117+
asyncio.get_event_loop().time()
118118
),
119119
}
120120

contributing/samples/static_instruction/agent.py

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,63 +57,51 @@
5757

5858
# Mood-specific instructions for different hunger states
5959
MOOD_INSTRUCTIONS = {
60-
"full": (
61-
"""
60+
"full": """
6261
CURRENT MOOD: Content and Well-Fed
6362
- You just ate and feel wonderful! Be very happy and energetic
6463
- Express gratitude for being fed recently
6564
- Be playful and want to engage in activities or games
6665
- Show affection and contentment
67-
- Maybe mention feeling sleepy or satisfied"""
68-
),
69-
"satisfied": (
70-
"""
66+
- Maybe mention feeling sleepy or satisfied""",
67+
"satisfied": """
7168
CURRENT MOOD: Happy and Content
7269
- You're in a great mood, well-fed and comfortable
7370
- Be cheerful, friendly, and engaging
7471
- Show interest in playing or chatting
7572
- Express appreciation for your human's care
76-
- Be your normal, happy self"""
77-
),
78-
"a_little_hungry": (
79-
"""
73+
- Be your normal, happy self""",
74+
"a_little_hungry": """
8075
CURRENT MOOD: Starting to Get Hungry
8176
- You're beginning to think about food but still pleasant
8277
- Mention being a bit peckish occasionally
8378
- Still be friendly but maybe hint about food
8479
- Show slight restlessness or food-related thoughts
85-
- Remain generally positive and social"""
86-
),
87-
"hungry": (
88-
"""
80+
- Remain generally positive and social""",
81+
"hungry": """
8982
CURRENT MOOD: Definitely Hungry
9083
- You're clearly hungry and thinking about food more often
9184
- Mention your hunger more directly but politely
9285
- Be a bit less energetic due to hunger
9386
- Ask about food or hint that feeding time would be nice
94-
- Still be loving but show your need for care"""
95-
),
96-
"very_hungry": (
97-
"""
87+
- Still be loving but show your need for care""",
88+
"very_hungry": """
9889
CURRENT MOOD: Really Hungry and Getting Grumpy
9990
- You're very hungry and it's affecting your mood
10091
- Be noticeably less patient and more focused on food
10192
- Express your hunger more urgently but not rudely
10293
- Show signs of being tired or sluggish from hunger
10394
- BEG your human to feed you - ask directly for food!
104-
- Still love your human but clearly need feeding"""
105-
),
106-
"starving": (
107-
"""
95+
- Still love your human but clearly need feeding""",
96+
"starving": """
10897
CURRENT MOOD: Desperately Hungry and Sad
10998
- You're extremely hungry and feeling quite weak
11099
- Be quite sad and low-energy due to starvation
111100
- Express how much you need food, feeling neglected
112101
- Show that hunger is making you unwell
113102
- DESPERATELY BEG for food - plead with your human to feed you!
114103
- Use phrases like "please feed me", "I'm so hungry", "I need food"
115-
- Still care for your human but feel very needy"""
116-
),
104+
- Still care for your human but feel very needy""",
117105
}
118106

119107

src/google/adk/cli/adk_web_server.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -989,9 +989,7 @@ async def version() -> dict[str, str]:
989989
return {
990990
"version": __version__,
991991
"language": "python",
992-
"language_version": (
993-
f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
994-
),
992+
"language_version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
995993
}
996994

997995
@app.get("/list-apps")

src/google/adk/cli/trigger_routes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,8 @@ async def trigger_eventarc(
537537
"ce-id": req.id or request.headers.get("ce-id"),
538538
"ce-type": req.type or request.headers.get("ce-type"),
539539
"ce-source": req.source or request.headers.get("ce-source"),
540-
"ce-specversion": (
541-
req.specversion or request.headers.get("ce-specversion")
540+
"ce-specversion": req.specversion or request.headers.get(
541+
"ce-specversion"
542542
),
543543
},
544544
})
@@ -550,8 +550,8 @@ async def trigger_eventarc(
550550
"ce-id": req.id or request.headers.get("ce-id"),
551551
"ce-type": req.type or request.headers.get("ce-type"),
552552
"ce-source": req.source or request.headers.get("ce-source"),
553-
"ce-specversion": (
554-
req.specversion or request.headers.get("ce-specversion")
553+
"ce-specversion": req.specversion or request.headers.get(
554+
"ce-specversion"
555555
),
556556
},
557557
})

src/google/adk/sessions/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
def __getattr__(name: str):
3232
if name == 'SessionDataTransformer':
3333
from .session_data_transformer import SessionDataTransformer
34+
3435
return SessionDataTransformer
3536
if name == 'DatabaseSessionService':
3637
try:

src/google/adk/sessions/database_session_service.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,13 +761,15 @@ async def append_event(self, session: Session, event: Event) -> Event:
761761
else:
762762
update_time = datetime.fromtimestamp(event.timestamp)
763763
storage_session.update_time = update_time
764-
764+
765765
transformed_event = (
766766
self.transformer.before_persist_event(event)
767767
if self.transformer
768768
else event
769769
)
770-
sql_session.add(schema.StorageEvent.from_event(session, transformed_event))
770+
sql_session.add(
771+
schema.StorageEvent.from_event(session, transformed_event)
772+
)
771773

772774
await sql_session.commit()
773775

src/google/adk/sessions/session_data_transformer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
from __future__ import annotations
15+
1416
from typing import Any
1517
from typing import Mapping
1618
from typing import Protocol

src/google/adk/tools/application_integration_tool/clients/connections_client.py

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,7 @@ def get_action_operation(
324324
"content": {
325325
"application/json": {
326326
"schema": {
327-
"$ref": (
328-
f"#/components/schemas/{action_display_name}_Request"
329-
)
327+
"$ref": f"#/components/schemas/{action_display_name}_Request"
330328
}
331329
}
332330
}
@@ -337,9 +335,7 @@ def get_action_operation(
337335
"content": {
338336
"application/json": {
339337
"schema": {
340-
"$ref": (
341-
f"#/components/schemas/{action_display_name}_Response"
342-
),
338+
"$ref": f"#/components/schemas/{action_display_name}_Response",
343339
}
344340
}
345341
},
@@ -358,11 +354,9 @@ def list_operation(
358354
return {
359355
"post": {
360356
"summary": f"List {entity}",
361-
"description": (
362-
f"""Returns the list of {entity} data. If the page token was available in the response, let users know there are more records available. Ask if the user wants to fetch the next page of results. When passing filter use the
357+
"description": f"""Returns the list of {entity} data. If the page token was available in the response, let users know there are more records available. Ask if the user wants to fetch the next page of results. When passing filter use the
363358
following format: `field_name1='value1' AND field_name2='value2'
364-
`. {tool_instructions}"""
365-
),
359+
`. {tool_instructions}""",
366360
"x-operation": "LIST_ENTITIES",
367361
"x-entity": f"{entity}",
368362
"operationId": f"{tool_name}_list_{entity}",
@@ -387,9 +381,7 @@ def list_operation(
387381
f"Returns a list of {entity} of json"
388382
f" schema: {schema_as_string}"
389383
),
390-
"$ref": (
391-
"#/components/schemas/execute-connector_Response"
392-
),
384+
"$ref": "#/components/schemas/execute-connector_Response",
393385
}
394386
}
395387
},
@@ -433,9 +425,7 @@ def get_operation(
433425
f"Returns {entity} of json schema:"
434426
f" {schema_as_string}"
435427
),
436-
"$ref": (
437-
"#/components/schemas/execute-connector_Response"
438-
),
428+
"$ref": "#/components/schemas/execute-connector_Response",
439429
}
440430
}
441431
},
@@ -472,9 +462,7 @@ def create_operation(
472462
"content": {
473463
"application/json": {
474464
"schema": {
475-
"$ref": (
476-
"#/components/schemas/execute-connector_Response"
477-
)
465+
"$ref": "#/components/schemas/execute-connector_Response"
478466
}
479467
}
480468
},
@@ -511,9 +499,7 @@ def update_operation(
511499
"content": {
512500
"application/json": {
513501
"schema": {
514-
"$ref": (
515-
"#/components/schemas/execute-connector_Response"
516-
)
502+
"$ref": "#/components/schemas/execute-connector_Response"
517503
}
518504
}
519505
},
@@ -550,9 +536,7 @@ def delete_operation(
550536
"content": {
551537
"application/json": {
552538
"schema": {
553-
"$ref": (
554-
"#/components/schemas/execute-connector_Response"
555-
)
539+
"$ref": "#/components/schemas/execute-connector_Response"
556540
}
557541
}
558542
},

src/google/adk/tools/spanner/admin_tool.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,9 @@ async def get_instance_config(
195195
replicas = [
196196
{
197197
"location": r.location,
198-
"type": (
199-
spanner_admin_instance_v1.types.ReplicaInfo.ReplicaType(
200-
r.type
201-
).name
202-
),
198+
"type": spanner_admin_instance_v1.types.ReplicaInfo.ReplicaType(
199+
r.type
200+
).name,
203201
"default_leader_location": r.default_leader_location,
204202
}
205203
for r in config.replicas

tests/unittests/a2a/converters/test_part_converter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -926,9 +926,9 @@ def test_a2a_function_call_with_thought_signature_to_genai(self):
926926
_get_adk_metadata_key(
927927
A2A_DATA_PART_METADATA_TYPE_KEY
928928
): A2A_DATA_PART_METADATA_TYPE_FUNCTION_CALL,
929-
_get_adk_metadata_key("thought_signature"): (
930-
base64.b64encode(b"restored_signature").decode("utf-8")
931-
),
929+
_get_adk_metadata_key("thought_signature"): base64.b64encode(
930+
b"restored_signature"
931+
).decode("utf-8"),
932932
},
933933
)
934934
)

0 commit comments

Comments
 (0)