@@ -407,7 +407,12 @@ def _get_formatted_annotation(annotation: TypeVar) -> TypeVar:
407
407
elif what == "method" :
408
408
# bail if it is a local method as we cannot determine if first argument needs to be deleted or not
409
409
if "<locals>" in obj .__qualname__ and not _is_dataclass (name , what , obj .__qualname__ ):
410
- _LOGGER .warning ('Cannot handle as a local function: "%s" (use @functools.wraps)' , name , type = 'sphinx_autodoc_typehints' , subtype = 'local_function' )
410
+ _LOGGER .warning (
411
+ 'Cannot handle as a local function: "%s" (use @functools.wraps)' ,
412
+ name ,
413
+ type = "sphinx_autodoc_typehints" ,
414
+ subtype = "local_function" ,
415
+ )
411
416
return None
412
417
outer = inspect .getmodule (obj )
413
418
for class_name in obj .__qualname__ .split ("." )[:- 1 ]:
@@ -500,7 +505,9 @@ def _execute_guarded_code(autodoc_mock_imports: list[str], obj: Any, module_code
500
505
with mock (autodoc_mock_imports ):
501
506
exec (guarded_code , getattr (obj , "__globals__" , obj .__dict__ )) # noqa: S102
502
507
except Exception as exc : # noqa: BLE001
503
- _LOGGER .warning ("Failed guarded type import with %r" , exc , type = 'sphinx_autodoc_typehints' , subtype = 'guarded_import' )
508
+ _LOGGER .warning (
509
+ "Failed guarded type import with %r" , exc , type = "sphinx_autodoc_typehints" , subtype = "guarded_import"
510
+ )
504
511
505
512
506
513
def _resolve_type_guarded_imports (autodoc_mock_imports : list [str ], obj : Any ) -> None :
@@ -536,7 +543,13 @@ def _get_type_hint(
536
543
else :
537
544
result = {}
538
545
except NameError as exc :
539
- _LOGGER .warning ('Cannot resolve forward reference in type annotations of "%s": %s' , name , exc , type = 'sphinx_autodoc_typehints' , subtype = 'forward_reference' )
546
+ _LOGGER .warning (
547
+ 'Cannot resolve forward reference in type annotations of "%s": %s' ,
548
+ name ,
549
+ exc ,
550
+ type = "sphinx_autodoc_typehints" ,
551
+ subtype = "forward_reference" ,
552
+ )
540
553
result = obj .__annotations__
541
554
return result
542
555
@@ -554,7 +567,12 @@ def backfill_type_hints(obj: Any, name: str) -> dict[str, Any]: # noqa: C901, P
554
567
def _one_child (module : Module ) -> stmt | None :
555
568
children = module .body # use the body to ignore type comments
556
569
if len (children ) != 1 :
557
- _LOGGER .warning ('Did not get exactly one node from AST for "%s", got %s' , name , len (children ), type = 'sphinx_autodoc_typehints' )
570
+ _LOGGER .warning (
571
+ 'Did not get exactly one node from AST for "%s", got %s' ,
572
+ name ,
573
+ len (children ),
574
+ type = "sphinx_autodoc_typehints" ,
575
+ )
558
576
return None
559
577
return children [0 ]
560
578
@@ -579,7 +597,12 @@ def _one_child(module: Module) -> stmt | None:
579
597
try :
580
598
comment_args_str , comment_returns = type_comment .split (" -> " )
581
599
except ValueError :
582
- _LOGGER .warning ('Unparseable type hint comment for "%s": Expected to contain ` -> `' , name , type = 'sphinx_autodoc_typehints' , subtype = 'comment' )
600
+ _LOGGER .warning (
601
+ 'Unparseable type hint comment for "%s": Expected to contain ` -> `' ,
602
+ name ,
603
+ type = "sphinx_autodoc_typehints" ,
604
+ subtype = "comment" ,
605
+ )
583
606
return {}
584
607
585
608
rv = {}
@@ -594,7 +617,9 @@ def _one_child(module: Module) -> stmt | None:
594
617
comment_args .insert (0 , None ) # self/cls may be omitted in type comments, insert blank
595
618
596
619
if len (args ) != len (comment_args ):
597
- _LOGGER .warning ('Not enough type comments found on "%s"' , name , type = 'sphinx_autodoc_typehints' , subtype = 'comment' )
620
+ _LOGGER .warning (
621
+ 'Not enough type comments found on "%s"' , name , type = "sphinx_autodoc_typehints" , subtype = "comment"
622
+ )
598
623
return rv
599
624
600
625
for at , arg in enumerate (args ):
0 commit comments