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