File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515from __future__ import annotations
1616
1717from typing import Optional
18+ from typing import Any
19+ from typing import cast
1820
1921from google .adk .platform import time as platform_time
2022from google .adk .platform import uuid as platform_uuid
@@ -73,7 +75,7 @@ class Event(LlmResponse):
7375 timestamp : float = Field (default_factory = lambda : platform_time .get_time ())
7476 """The timestamp of the event."""
7577
76- def model_post_init (self , __context ) :
78+ def model_post_init (self , __context : Any ) -> None :
7779 """Post initialization logic for the event."""
7880 # Generates a random ID for the event.
7981 if not self .id :
@@ -124,5 +126,5 @@ def has_trailing_code_execution_result(
124126 return False
125127
126128 @staticmethod
127- def new_id ():
128- return platform_uuid .new_uuid ()
129+ def new_id () -> str :
130+ return cast ( str , platform_uuid .new_uuid () )
Original file line number Diff line number Diff line change 2222
2323class TestTime (unittest .TestCase ):
2424
25- def tearDown (self ):
25+ def tearDown (self ) -> None :
2626 # Reset provider to default after each test
2727 platform_time .reset_time_provider ()
2828
29- def test_default_time_provider (self ):
29+ def test_default_time_provider (self ) -> None :
3030 # Verify it returns a float that is close to now
3131 now = time .time ()
3232 rt_time = platform_time .get_time ()
3333 self .assertIsInstance (rt_time , float )
3434 self .assertAlmostEqual (rt_time , now , delta = 1.0 )
3535
36- def test_custom_time_provider (self ):
36+ def test_custom_time_provider (self ) -> None :
3737 # Test override
3838 mock_time = 123456789.0
3939 platform_time .set_time_provider (lambda : mock_time )
Original file line number Diff line number Diff line change 2222
2323class TestUUID (unittest .TestCase ):
2424
25- def tearDown (self ):
25+ def tearDown (self ) -> None :
2626 # Reset provider to default after each test
2727 platform_uuid .reset_id_provider ()
2828
29- def test_default_id_provider (self ):
29+ def test_default_id_provider (self ) -> None :
3030 # Verify it returns a string uuid
3131 uid = platform_uuid .new_uuid ()
3232 self .assertIsInstance (uid , str )
3333 # Should be parseable as uuid
3434 uuid .UUID (uid )
3535
36- def test_custom_id_provider (self ):
36+ def test_custom_id_provider (self ) -> None :
3737 # Test override
3838 mock_id = "test-id-123"
3939 platform_uuid .set_id_provider (lambda : mock_id )
You can’t perform that action at this time.
0 commit comments