@@ -1011,41 +1011,42 @@ def format_args(self, **kwargs: Any) -> str:
1011
1011
if self .env .config .autodoc_typehints in ('none' , 'description' ):
1012
1012
kwargs .setdefault ('show_annotation' , False )
1013
1013
1014
- if ((inspect .isbuiltin (self .object ) or inspect .ismethoddescriptor (self .object )) and
1015
- not inspect .is_cython_function_or_method (self .object )):
1014
+ unwrapped = inspect .unwrap (self .object )
1015
+ if ((inspect .isbuiltin (unwrapped ) or inspect .ismethoddescriptor (unwrapped )) and
1016
+ not inspect .is_cython_function_or_method (unwrapped )):
1016
1017
# cannot introspect arguments of a C function or method
1017
1018
return None
1018
1019
try :
1019
- if (not inspect .isfunction (self . object ) and
1020
- not inspect .ismethod (self . object ) and
1021
- not inspect .isbuiltin (self . object ) and
1022
- not inspect .is_cython_function_or_method (self . object ) and
1023
- not inspect .isclass (self . object ) and
1024
- hasattr (self . object , '__call__' )):
1020
+ if (not inspect .isfunction (unwrapped ) and
1021
+ not inspect .ismethod (unwrapped ) and
1022
+ not inspect .isbuiltin (unwrapped ) and
1023
+ not inspect .is_cython_function_or_method (unwrapped ) and
1024
+ not inspect .isclass (unwrapped ) and
1025
+ hasattr (unwrapped , '__call__' )):
1025
1026
self .env .app .emit ('autodoc-before-process-signature' ,
1026
- self . object .__call__ , False )
1027
- sig = inspect .signature (self . object .__call__ )
1027
+ unwrapped .__call__ , False )
1028
+ sig = inspect .signature (unwrapped .__call__ )
1028
1029
else :
1029
- self .env .app .emit ('autodoc-before-process-signature' , self . object , False )
1030
- sig = inspect .signature (self . object )
1030
+ self .env .app .emit ('autodoc-before-process-signature' , unwrapped , False )
1031
+ sig = inspect .signature (unwrapped )
1031
1032
args = stringify_signature (sig , ** kwargs )
1032
1033
except TypeError :
1033
- if (inspect .is_builtin_class_method (self . object , '__new__' ) and
1034
- inspect .is_builtin_class_method (self . object , '__init__' )):
1035
- raise TypeError ('%r is a builtin class' % self . object )
1034
+ if (inspect .is_builtin_class_method (unwrapped , '__new__' ) and
1035
+ inspect .is_builtin_class_method (unwrapped , '__init__' )):
1036
+ raise TypeError ('%r is a builtin class' % unwrapped )
1036
1037
1037
1038
# if a class should be documented as function (yay duck
1038
1039
# typing) we try to use the constructor signature as function
1039
1040
# signature without the first argument.
1040
1041
try :
1041
1042
self .env .app .emit ('autodoc-before-process-signature' ,
1042
- self . object .__new__ , True )
1043
- sig = inspect .signature (self . object .__new__ , bound_method = True )
1043
+ unwrapped .__new__ , True )
1044
+ sig = inspect .signature (unwrapped .__new__ , bound_method = True )
1044
1045
args = stringify_signature (sig , show_return_annotation = False , ** kwargs )
1045
1046
except TypeError :
1046
1047
self .env .app .emit ('autodoc-before-process-signature' ,
1047
- self . object .__init__ , True )
1048
- sig = inspect .signature (self . object .__init__ , bound_method = True )
1048
+ unwrapped .__init__ , True )
1049
+ sig = inspect .signature (unwrapped .__init__ , bound_method = True )
1049
1050
args = stringify_signature (sig , show_return_annotation = False , ** kwargs )
1050
1051
1051
1052
if self .env .config .strip_signature_backslash :
@@ -1432,16 +1433,17 @@ def format_args(self, **kwargs: Any) -> str:
1432
1433
if self .env .config .autodoc_typehints == 'none' :
1433
1434
kwargs .setdefault ('show_annotation' , False )
1434
1435
1435
- if ((inspect .isbuiltin (self .object ) or inspect .ismethoddescriptor (self .object )) and
1436
- not inspect .is_cython_function_or_method (self .object )):
1436
+ unwrapped = inspect .unwrap (self .object )
1437
+ if ((inspect .isbuiltin (unwrapped ) or inspect .ismethoddescriptor (unwrapped )) and
1438
+ not inspect .is_cython_function_or_method (unwrapped )):
1437
1439
# can never get arguments of a C function or method
1438
1440
return None
1439
- if inspect .isstaticmethod (self . object , cls = self .parent , name = self .object_name ):
1440
- self .env .app .emit ('autodoc-before-process-signature' , self . object , False )
1441
- sig = inspect .signature (self . object , bound_method = False )
1441
+ if inspect .isstaticmethod (unwrapped , cls = self .parent , name = self .object_name ):
1442
+ self .env .app .emit ('autodoc-before-process-signature' , unwrapped , False )
1443
+ sig = inspect .signature (unwrapped , bound_method = False )
1442
1444
else :
1443
- self .env .app .emit ('autodoc-before-process-signature' , self . object , True )
1444
- sig = inspect .signature (self . object , bound_method = True )
1445
+ self .env .app .emit ('autodoc-before-process-signature' , unwrapped , True )
1446
+ sig = inspect .signature (unwrapped , bound_method = True )
1445
1447
args = stringify_signature (sig , ** kwargs )
1446
1448
1447
1449
if self .env .config .strip_signature_backslash :
0 commit comments