@@ -74,9 +74,7 @@ def file(
7474 ) -> a2a_pb2 .FilePart :
7575 if isinstance (file , types .FileWithUri ):
7676 return a2a_pb2 .FilePart (
77- file_with_uri = file .uri ,
78- mime_type = file .mime_type ,
79- name = file .name
77+ file_with_uri = file .uri , mime_type = file .mime_type , name = file .name
8078 )
8179 return a2a_pb2 .FilePart (
8280 file_with_bytes = file .bytes .encode ('utf-8' ),
@@ -332,7 +330,9 @@ def extension(
332330 return a2a_pb2 .AgentExtension (
333331 uri = extension .uri ,
334332 description = extension .description ,
335- params = dict_to_struct (extension .params ) if extension .params else None ,
333+ params = dict_to_struct (extension .params )
334+ if extension .params
335+ else None ,
336336 required = extension .required ,
337337 )
338338
@@ -487,9 +487,9 @@ def message(cls, message: a2a_pb2.Message) -> types.Message:
487487
488488 @classmethod
489489 def metadata (cls , metadata : struct_pb2 .Struct ) -> dict [str , Any ]:
490- if not metadata .fields :
490+ if not metadata .fields :
491491 return {}
492- return struct_to_dict (metadata )
492+ return struct_to_dict (metadata )
493493
494494 @classmethod
495495 def part (cls , part : a2a_pb2 .Part ) -> types .Part :
@@ -942,33 +942,32 @@ def role(cls, role: a2a_pb2.Role) -> types.Role:
942942
943943
944944def struct_to_dict (struct : struct_pb2 .Struct ) -> dict [str , Any ]:
945- """Converts a Struct proto to a Python dict."""
946-
947- def convert (value : struct_pb2 .Value ) -> Any :
948- if value .HasField ('list_value' ):
949- return [convert (v ) for v in value .list_value .values ]
950- if value .HasField ('struct_value' ):
951- return {k : convert (v ) for k , v in value .struct_value .fields .items ()}
952- if value .HasField ('number_value' ):
953- return value .number_value
954- if value .HasField ('string_value' ):
955- return value .string_value
956- if value .HasField ('bool_value' ):
957- return value .bool_value
958- if value .HasField ('null_value' ):
959- return None
960- raise ValueError (f'Unsupported type: { value } ' )
961-
962- return {k : convert (v ) for k , v in struct .fields .items ()}
945+ """Converts a Struct proto to a Python dict."""
946+
947+ def convert (value : struct_pb2 .Value ) -> Any :
948+ if value .HasField ('list_value' ):
949+ return [convert (v ) for v in value .list_value .values ]
950+ if value .HasField ('struct_value' ):
951+ return {k : convert (v ) for k , v in value .struct_value .fields .items ()}
952+ if value .HasField ('number_value' ):
953+ return value .number_value
954+ if value .HasField ('string_value' ):
955+ return value .string_value
956+ if value .HasField ('bool_value' ):
957+ return value .bool_value
958+ if value .HasField ('null_value' ):
959+ return None
960+ raise ValueError (f'Unsupported type: { value } ' )
963961
962+ return {k : convert (v ) for k , v in struct .fields .items ()}
964963
965- def dict_to_struct (dictionary : dict [str , Any ]) -> struct_pb2 .Struct :
966- """Converts a Python dict to a Struct proto."""
967- struct = struct_pb2 .Struct ()
968- for key , val in dictionary .items ():
969- if isinstance (val , dict ):
970- struct [key ] = dict_to_struct (val )
971- else :
972- struct [key ] = val
973- return struct
974964
965+ def dict_to_struct (dictionary : dict [str , Any ]) -> struct_pb2 .Struct :
966+ """Converts a Python dict to a Struct proto."""
967+ struct = struct_pb2 .Struct ()
968+ for key , val in dictionary .items ():
969+ if isinstance (val , dict ):
970+ struct [key ] = dict_to_struct (val )
971+ else :
972+ struct [key ] = val
973+ return struct
0 commit comments