@@ -916,20 +916,18 @@ def docroutine(self, object, name=None, mod=None,
916916 reallink = realname
917917 title = '<a name="%s"><strong>%s</strong></a> = %s' % (
918918 anchor , name , reallink )
919- if inspect .isfunction (object ):
920- args , varargs , kwonlyargs , kwdefaults , varkw , defaults , ann = \
921- inspect .getfullargspec (object )
922- argspec = inspect .formatargspec (
923- args , varargs , kwonlyargs , kwdefaults , varkw , defaults , ann ,
924- formatvalue = self .formatvalue ,
925- formatannotation = inspect .formatannotationrelativeto (object ))
926- if realname == '<lambda>' :
927- title = '<strong>%s</strong> <em>lambda</em> ' % name
928- # XXX lambda's won't usually have func_annotations['return']
929- # since the syntax doesn't support but it is possible.
930- # So removing parentheses isn't truly safe.
931- argspec = argspec [1 :- 1 ] # remove parentheses
932- else :
919+ argspec = None
920+ if inspect .isfunction (object ) or inspect .isbuiltin (object ):
921+ signature = inspect .signature (object )
922+ if signature :
923+ argspec = str (signature )
924+ if realname == '<lambda>' :
925+ title = '<strong>%s</strong> <em>lambda</em> ' % name
926+ # XXX lambda's won't usually have func_annotations['return']
927+ # since the syntax doesn't support but it is possible.
928+ # So removing parentheses isn't truly safe.
929+ argspec = argspec [1 :- 1 ] # remove parentheses
930+ if not argspec :
933931 argspec = '(...)'
934932
935933 decl = title + argspec + (note and self .grey (
@@ -1313,20 +1311,18 @@ def docroutine(self, object, name=None, mod=None, cl=None):
13131311 cl .__dict__ [realname ] is object ):
13141312 skipdocs = 1
13151313 title = self .bold (name ) + ' = ' + realname
1316- if inspect .isfunction (object ):
1317- args , varargs , varkw , defaults , kwonlyargs , kwdefaults , ann = \
1318- inspect .getfullargspec (object )
1319- argspec = inspect .formatargspec (
1320- args , varargs , varkw , defaults , kwonlyargs , kwdefaults , ann ,
1321- formatvalue = self .formatvalue ,
1322- formatannotation = inspect .formatannotationrelativeto (object ))
1323- if realname == '<lambda>' :
1324- title = self .bold (name ) + ' lambda '
1325- # XXX lambda's won't usually have func_annotations['return']
1326- # since the syntax doesn't support but it is possible.
1327- # So removing parentheses isn't truly safe.
1328- argspec = argspec [1 :- 1 ] # remove parentheses
1329- else :
1314+ argspec = None
1315+ if inspect .isfunction (object ) or inspect .isbuiltin (object ):
1316+ signature = inspect .signature (object )
1317+ if signature :
1318+ argspec = str (signature )
1319+ if realname == '<lambda>' :
1320+ title = self .bold (name ) + ' lambda '
1321+ # XXX lambda's won't usually have func_annotations['return']
1322+ # since the syntax doesn't support but it is possible.
1323+ # So removing parentheses isn't truly safe.
1324+ argspec = argspec [1 :- 1 ] # remove parentheses
1325+ if not argspec :
13301326 argspec = '(...)'
13311327 decl = title + argspec + note
13321328
0 commit comments