@@ -353,37 +353,38 @@ def get_client_method_map(self) -> dict[str, Method]:
353353 ),
354354 )
355355 if operation_model .input_shape :
356- self ._create_request_type_annotation (
356+ self .create_request_type_annotation (
357357 method = method ,
358- input_shape = operation_model .input_shape ,
358+ name = operation_model .input_shape . name ,
359359 optional_postfix = "Request" ,
360360 )
361361 result [method .name ] = method
362362 return result
363363
364- def _create_request_type_annotation (
365- self , method : Method , input_shape : Shape , optional_postfix : str
364+ def create_request_type_annotation (
365+ self , method : Method , name : str , optional_postfix : str = "Extra"
366366 ) -> None :
367+ """
368+ Create a request type annotation for the given method and input shape.
369+ """
367370 method .create_request_type_annotation (
368- self ._get_non_clashing_typed_dict_name_for_shape (
369- input_shape ,
370- optional_postfix = "Request" ,
371+ self ._get_non_clashing_typed_dict_name (
372+ name ,
373+ optional_postfix = optional_postfix ,
371374 )
372375 )
373376 if method .has_request_type_annotation ():
374377 self ._request_typed_dict_map .add (method .request_type_annotation )
375378
376- def _get_non_clashing_typed_dict_name_for_shape (
377- self , shape : Shape , optional_postfix : str
378- ) -> str :
379- temp_typed_dict = TypeTypedDict (self ._get_typed_dict_name (shape ), ())
380- return self ._get_non_clashing_typed_dict_name (
379+ def _get_non_clashing_typed_dict_name (self , name : str , optional_postfix : str ) -> str :
380+ temp_typed_dict = TypeTypedDict (get_type_def_name (name ), ())
381+ return self ._get_non_clashing_typed_dict_name_for_existing (
381382 temp_typed_dict ,
382383 optional_postfix = optional_postfix ,
383384 )
384385
385386 @staticmethod
386- def _get_typed_dict_name (shape : Shape , postfix : str = "" ) -> str :
387+ def _get_typed_dict_name_for_shape (shape : Shape , postfix : str = "" ) -> str :
387388 return get_type_def_name (shape .name , postfix )
388389
389390 @staticmethod
@@ -478,7 +479,9 @@ def _parse_shape_structure(
478479 typed_dict = TypeTypedDict (typed_dict_name )
479480
480481 typed_dict_map = self ._get_typed_dict_map (output = output , output_child = output_child )
481- resource_typed_dict_name = self ._get_typed_dict_name (shape , postfix = self .resource_name )
482+ resource_typed_dict_name = self ._get_typed_dict_name_for_shape (
483+ shape , postfix = self .resource_name
484+ )
482485 found_typed_dict = typed_dict_map .get (typed_dict .name )
483486 found_resource_typed_dict = typed_dict_map .get (resource_typed_dict_name )
484487
@@ -550,7 +553,7 @@ def _parse_shape_list(
550553
551554 def _get_shape_type_name (self , shape : Shape ) -> str :
552555 if isinstance (shape , StructureShape ):
553- return self ._get_typed_dict_name (shape )
556+ return self ._get_typed_dict_name_for_shape (shape )
554557
555558 if isinstance (shape , StringShape ):
556559 return shape .name
@@ -740,9 +743,9 @@ def get_paginate_method(self, paginator_name: str) -> Method:
740743 type_ignore = "override" ,
741744 )
742745 if operation_model .input_shape is not None :
743- self ._create_request_type_annotation (
746+ self .create_request_type_annotation (
744747 method = method ,
745- input_shape = operation_model .input_shape ,
748+ name = operation_model .input_shape . name ,
746749 optional_postfix = "Paginate" ,
747750 )
748751 return method
@@ -792,9 +795,9 @@ def get_wait_method(self, waiter_name: str) -> Method:
792795 type_ignore = "override" ,
793796 )
794797 if operation_model .input_shape is not None :
795- self ._create_request_type_annotation (
798+ self .create_request_type_annotation (
796799 method = method ,
797- input_shape = operation_model .input_shape ,
800+ name = operation_model .input_shape . name ,
798801 optional_postfix = "Wait" ,
799802 )
800803 return method
@@ -1123,9 +1126,9 @@ def _get_resource_method(self, action_name: str, action_shape: ActionShape) -> M
11231126 ),
11241127 )
11251128 if operation_model .input_shape is not None :
1126- self ._create_request_type_annotation (
1129+ self .create_request_type_annotation (
11271130 method = method ,
1128- input_shape = operation_model .input_shape ,
1131+ name = operation_model .input_shape . name ,
11291132 optional_postfix = f"{ self .resource_name } { action_name } " ,
11301133 )
11311134 return method
@@ -1233,7 +1236,7 @@ def _get_typed_dict(
12331236 return typed_dict_map [name ]
12341237 return None
12351238
1236- def _get_non_clashing_typed_dict_name (
1239+ def _get_non_clashing_typed_dict_name_for_existing (
12371240 self ,
12381241 typed_dict : TypeTypedDict ,
12391242 postfix : str = "" ,
@@ -1264,7 +1267,10 @@ def _get_non_clashing_typed_dict_name(
12641267 f"Clashing typed dict name found: { new_typed_dict_name } " ,
12651268 tags = new_typed_dict_name ,
12661269 )
1267- return self ._get_non_clashing_typed_dict_name (temp_typed_dict , postfix = optional_postfix )
1270+ return self ._get_non_clashing_typed_dict_name_for_existing (
1271+ temp_typed_dict ,
1272+ postfix = optional_postfix ,
1273+ )
12681274
12691275 def fix_typed_dict_names (self ) -> None :
12701276 """
@@ -1284,7 +1290,7 @@ def fix_typed_dict_names(self) -> None:
12841290 continue
12851291
12861292 old_typed_dict_name = output_typed_dict .name
1287- new_typed_dict_name = self ._get_non_clashing_typed_dict_name (
1293+ new_typed_dict_name = self ._get_non_clashing_typed_dict_name_for_existing (
12881294 output_typed_dict ,
12891295 "Output" ,
12901296 )
@@ -1318,7 +1324,7 @@ def fix_typed_dict_names(self) -> None:
13181324 continue
13191325
13201326 old_typed_dict_name = response_typed_dict .name
1321- new_typed_dict_name = self ._get_non_clashing_typed_dict_name (
1327+ new_typed_dict_name = self ._get_non_clashing_typed_dict_name_for_existing (
13221328 response_typed_dict ,
13231329 postfix = "Response" ,
13241330 )
@@ -1346,7 +1352,9 @@ def convert_input_arguments_to_unions(
13461352 if argument .type_annotation and is_type_parent (argument .type_annotation )
13471353 )
13481354 for input_typed_dict , output_typed_dict in self ._fixed_typed_dict_map .items ():
1349- union_name = self ._get_non_clashing_typed_dict_name (input_typed_dict , postfix = "Union" )
1355+ union_name = self ._get_non_clashing_typed_dict_name_for_existing (
1356+ input_typed_dict , postfix = "Union"
1357+ )
13501358 union_type_annotation = TypeUnion (
13511359 name = union_name ,
13521360 children = (input_typed_dict , output_typed_dict ),
0 commit comments