@@ -94,10 +94,12 @@ def get_annotation_args(annotation, module: str, class_name: str) -> Tuple:
94
94
return getattr (annotation , "__args__" , ())
95
95
96
96
97
- def format_annotation (annotation : Any ,
98
- fully_qualified : bool = False ,
99
- simplify_optional_unions : bool = True ,
100
- typehints_formatter : Callable = lambda _annotation , ** _opts : None ) -> str :
97
+ def format_annotation (
98
+ annotation : Any ,
99
+ fully_qualified : bool = False ,
100
+ simplify_optional_unions : bool = True ,
101
+ typehints_formatter : Callable = lambda _annotation , ** _opts : None ,
102
+ ) -> str :
101
103
# all options except for the formatter:
102
104
opts = dict (fully_qualified = fully_qualified , simplify_optional_unions = simplify_optional_unions )
103
105
formatted = typehints_formatter (annotation , ** opts )
@@ -466,7 +468,8 @@ def process_docstring(app, what, name, obj, options, lines): # noqa: U100
466
468
formatted_annotation = format_annotation (
467
469
annotation ,
468
470
fully_qualified = app .config .typehints_fully_qualified ,
469
- simplify_optional_unions = app .config .simplify_optional_unions )
471
+ simplify_optional_unions = app .config .simplify_optional_unions ,
472
+ )
470
473
471
474
search_for = [f":{ field } { arg_name } :" for field in ("param" , "parameter" , "arg" , "argument" )]
472
475
insert_index = None
@@ -489,8 +492,9 @@ def process_docstring(app, what, name, obj, options, lines): # noqa: U100
489
492
return
490
493
491
494
formatted_annotation = format_annotation (
492
- type_hints ['return' ], fully_qualified = app .config .typehints_fully_qualified ,
493
- simplify_optional_unions = app .config .simplify_optional_unions
495
+ type_hints ["return" ],
496
+ fully_qualified = app .config .typehints_fully_qualified ,
497
+ simplify_optional_unions = app .config .simplify_optional_unions ,
494
498
)
495
499
496
500
insert_index = len (lines )
@@ -522,7 +526,7 @@ def setup(app):
522
526
app .add_config_value ("typehints_fully_qualified" , False , "env" )
523
527
app .add_config_value ("typehints_document_rtype" , True , "env" )
524
528
app .add_config_value ("simplify_optional_unions" , True , "env" )
525
- app .add_config_value (' typehints_formatter' , lambda _annotation , ** _opts : None , ' env' )
529
+ app .add_config_value (" typehints_formatter" , lambda _annotation , ** _opts : None , " env" )
526
530
app .connect ("builder-inited" , builder_ready )
527
531
app .connect ("autodoc-process-signature" , process_signature )
528
532
app .connect ("autodoc-process-docstring" , process_docstring )
0 commit comments