99LOGGER = sphinx .util .logging .getLogger (__name__ )
1010
1111
12- def _format_args (args_info , include_annotations = True ):
12+ def _format_args (args_info , include_annotations = True , ignore_self = None ):
1313 result = []
1414
15- for prefix , name , annotation , default in args_info :
15+ for i , (prefix , name , annotation , default ) in enumerate (args_info ):
16+ if i == 0 and name == ignore_self :
17+ continue
1618 formatted = "{}{}{}{}" .format (
1719 prefix or "" ,
1820 name or "" ,
@@ -351,14 +353,14 @@ def args(self):
351353 args = ""
352354
353355 if self .constructor :
354- autodoc_typehints = getattr (self .app .config , "autodoc_typehints" , "signature" )
356+ autodoc_typehints = getattr (
357+ self .app .config , "autodoc_typehints" , "signature"
358+ )
355359 show_annotations = autodoc_typehints != "none" and not (
356360 autodoc_typehints == "description" and not self .constructor .overloads
357361 )
358362 args_data = self .constructor .obj ["args" ]
359- if args_data and args_data [0 ][1 ] == "self" :
360- args_data = args_data [1 :]
361- args = _format_args (args_data , show_annotations )
363+ args = _format_args (args_data , show_annotations , ignore_self = "self" )
362364
363365 return args
364366
@@ -368,10 +370,15 @@ def overloads(self):
368370
369371 if self .constructor :
370372 overload_data = self .constructor .obj ["overloads" ]
371- if overload_data and overload_data [0 ][1 ] == "self" :
372- overload_data = overload_data [1 :]
373+ autodoc_typehints = getattr (
374+ self .app .config , "autodoc_typehints" , "signature"
375+ )
376+ show_annotations = autodoc_typehints not in ("none" , "description" )
373377 overloads = [
374- (_format_args (args ), return_annotation )
378+ (
379+ _format_args (args , show_annotations , ignore_self = "self" ),
380+ return_annotation ,
381+ )
375382 for args , return_annotation in overload_data
376383 ]
377384
0 commit comments