@@ -126,7 +126,9 @@ class ClientInfo:
126126class DocStubGenerator :
127127 """Generate markdown API Reference stubs for AWS SDK for Python v4 clients."""
128128
129- def __init__ (self , client_dir : Path , output_dir : Path , service_name : str | None = None ) -> None :
129+ def __init__ (
130+ self , client_dir : Path , output_dir : Path , service_name : str | None = None
131+ ) -> None :
130132 """
131133 Initialize the documentation generator.
132134
@@ -190,7 +192,9 @@ def _analyze_client_package(self, package_name: str) -> ClientInfo:
190192 required = ("client" , "config" , "models" )
191193 missing = [name for name in required if not package .modules .get (name )]
192194 if missing :
193- raise ValueError (f"Missing required modules in { package_name } : { ', ' .join (missing )} " )
195+ raise ValueError (
196+ f"Missing required modules in { package_name } : { ', ' .join (missing )} "
197+ )
194198
195199 # Parse submodules
196200 client_module = package .modules ["client" ]
@@ -199,11 +203,15 @@ def _analyze_client_package(self, package_name: str) -> ClientInfo:
199203
200204 client_class = self ._find_class_with_suffix (client_module , "Client" )
201205 if not client_class :
202- raise ValueError (f"No class ending with 'Client' found in { package_name } .client" )
206+ raise ValueError (
207+ f"No class ending with 'Client' found in { package_name } .client"
208+ )
203209
204210 config_class = self ._find_class_with_suffix (config_module , "Config" )
205211 if not config_class :
206- raise ValueError (f"No class ending with 'Config' found in { package_name } .config" )
212+ raise ValueError (
213+ f"No class ending with 'Config' found in { package_name } .config"
214+ )
207215
208216 plugin_alias = config_module .members .get ("Plugin" )
209217 if not plugin_alias :
@@ -288,7 +296,9 @@ def _analyze_operation(self, operation: Function) -> OperationInfo:
288296
289297 if output_type in stream_type_map :
290298 stream_type = stream_type_map [output_type ]
291- stream_args = self ._get_subscript_elements (returns , f"'{ operation .name } ' stream type" )
299+ stream_args = self ._get_subscript_elements (
300+ returns , f"'{ operation .name } ' stream type"
301+ )
292302
293303 if stream_type in (StreamType .INPUT , StreamType .DUPLEX ):
294304 event_input_type = stream_args [0 ].canonical_name
@@ -316,7 +326,9 @@ def _analyze_operation(self, operation: Function) -> OperationInfo:
316326 def _get_expr (self , annotation : str | Expr | None , context : str ) -> Expr :
317327 """Extract and validate an Expr from an annotation."""
318328 if not isinstance (annotation , Expr ):
319- raise TypeError (f"{ context } : expected Expr, got { type (annotation ).__name__ } " )
329+ raise TypeError (
330+ f"{ context } : expected Expr, got { type (annotation ).__name__ } "
331+ )
320332 return annotation
321333
322334 def _get_subscript_elements (self , expr : Expr , context : str ) -> list [Expr ]:
@@ -330,7 +342,9 @@ def _get_subscript_elements(self, expr: Expr, context: str) -> list[Expr]:
330342 return [el for el in slice_expr .elements if isinstance (el , Expr )]
331343 return [slice_expr ]
332344
333- def _extract_models (self , models_module : Module , operations : list [OperationInfo ]) -> ModelsInfo :
345+ def _extract_models (
346+ self , models_module : Module , operations : list [OperationInfo ]
347+ ) -> ModelsInfo :
334348 """Extract structures, unions, enums, and errors from models module."""
335349 structures , unions , enums , errors = [], [], [], []
336350
@@ -356,14 +370,16 @@ def _extract_models(self, models_module: Module, operations: list[OperationInfo]
356370
357371 duplicates = []
358372 for structure in structures :
359- if self ._is_operation_io_type (structure . name , operations ) or self . _is_union_member (
360- structure .name , unions
361- ):
373+ if self ._is_operation_io_type (
374+ structure .name , operations
375+ ) or self . _is_union_member ( structure . name , unions ) :
362376 duplicates .append (structure )
363377
364378 structures = [struct for struct in structures if struct not in duplicates ]
365379
366- return ModelsInfo (structures = structures , unions = unions , enums = enums , errors = errors )
380+ return ModelsInfo (
381+ structures = structures , unions = unions , enums = enums , errors = errors
382+ )
367383
368384 def _is_union (self , member : Object | Alias ) -> TypeGuard [Attribute ]:
369385 """Check if a module member is a union type."""
@@ -399,7 +415,9 @@ def _extract_union_members(
399415 for name in member_names :
400416 if not (member_object := models_module .members .get (name )):
401417 raise ValueError (f"Union member '{ name } ' not found in models module" )
402- members .append (TypeInfo (name = member_object .name , module_path = member_object .path ))
418+ members .append (
419+ TypeInfo (name = member_object .name , module_path = member_object .path )
420+ )
403421
404422 return members
405423
@@ -408,18 +426,22 @@ def _is_enum(self, member: Object | Alias) -> TypeGuard[Class]:
408426 if not isinstance (member , Class ):
409427 return False
410428 return any (
411- isinstance (base , ExprName ) and base .name in ENUM_BASE_CLASSES for base in member .bases
429+ isinstance (base , ExprName ) and base .name in ENUM_BASE_CLASSES
430+ for base in member .bases
412431 )
413432
414433 def _is_error (self , member : Object | Alias ) -> TypeGuard [Class ]:
415434 """Check if a module member is an error."""
416435 if not isinstance (member , Class ):
417436 return False
418437 return any (
419- isinstance (base , ExprName ) and base .name in ERROR_BASE_CLASSES for base in member .bases
438+ isinstance (base , ExprName ) and base .name in ERROR_BASE_CLASSES
439+ for base in member .bases
420440 )
421441
422- def _is_operation_io_type (self , type_name : str , operations : list [OperationInfo ]) -> bool :
442+ def _is_operation_io_type (
443+ self , type_name : str , operations : list [OperationInfo ]
444+ ) -> bool :
423445 """Check if a type is used as operation input/output."""
424446 return any (type_name in (op .input .name , op .output .name ) for op in operations )
425447
@@ -437,8 +459,12 @@ def _generate_client_docs(self, client_info: ClientInfo) -> bool:
437459 self ._generate_type_stubs (
438460 client_info .models .structures , "structures" , "Structure Class"
439461 )
440- self ._generate_type_stubs (client_info .models .errors , "errors" , "Error Class" )
441- self ._generate_type_stubs (client_info .models .enums , "enums" , "Enum Class" , members = True )
462+ self ._generate_type_stubs (
463+ client_info .models .errors , "errors" , "Error Class"
464+ )
465+ self ._generate_type_stubs (
466+ client_info .models .enums , "enums" , "Enum Class" , members = True
467+ )
442468 self ._generate_union_stubs (client_info .models .unions )
443469 except OSError as e :
444470 logger .error (f"Failed to write documentation files: { e } " )
@@ -470,7 +496,9 @@ def _generate_index(self, client_info: ClientInfo) -> None:
470496 ]
471497
472498 for method in sorted (client_info .client_methods , key = lambda x : x .name ):
473- lines .extend ([* self ._mkdocs_directive (method .module_path , heading_level = 4 ), "" ])
499+ lines .extend (
500+ [* self ._mkdocs_directive (method .module_path , heading_level = 4 ), "" ]
501+ )
474502
475503 # Operations section
476504 if client_info .operations :
@@ -578,7 +606,9 @@ def _generate_operation_stubs(self, operations: list[OperationInfo]) -> None:
578606
579607 output_path = self .output_dir / "operations" / f"{ op .name } .md"
580608 output_path .parent .mkdir (parents = True , exist_ok = True )
581- output_path .write_text (self ._breadcrumb ("Operations" , op .name ) + "\n " .join (lines ))
609+ output_path .write_text (
610+ self ._breadcrumb ("Operations" , op .name ) + "\n " .join (lines )
611+ )
582612
583613 logger .info (f"Wrote { len (operations )} operation file(s)" )
584614
@@ -600,7 +630,9 @@ def _generate_type_stubs(
600630
601631 output_path = self .output_dir / category / f"{ item .name } .md"
602632 output_path .parent .mkdir (parents = True , exist_ok = True )
603- output_path .write_text (self ._breadcrumb (category .title (), item .name ) + "\n " .join (lines ))
633+ output_path .write_text (
634+ self ._breadcrumb (category .title (), item .name ) + "\n " .join (lines )
635+ )
604636
605637 logger .info (f"Wrote { len (items )} { category } file(s)" )
606638
@@ -624,7 +656,9 @@ def _generate_union_stubs(self, unions: list[UnionInfo]) -> None:
624656
625657 output_path = self .output_dir / "unions" / f"{ union .name } .md"
626658 output_path .parent .mkdir (parents = True , exist_ok = True )
627- output_path .write_text (self ._breadcrumb ("Unions" , union .name ) + "\n " .join (lines ))
659+ output_path .write_text (
660+ self ._breadcrumb ("Unions" , union .name ) + "\n " .join (lines )
661+ )
628662
629663 logger .info (f"Wrote { len (unions )} union file(s)" )
630664
0 commit comments