@@ -2121,7 +2121,7 @@ def _signature_from_builtin(cls, func, skip_bound_arg=True):
21212121 return _signature_fromstr (cls , func , s , skip_bound_arg )
21222122
21232123
2124- def _signature_from_function (cls , func ):
2124+ def _signature_from_function (cls , func , skip_bound_arg = True ):
21252125 """Private helper: constructs Signature for the given python function."""
21262126
21272127 is_duck_function = False
@@ -2133,6 +2133,10 @@ def _signature_from_function(cls, func):
21332133 # of pure function:
21342134 raise TypeError ('{!r} is not a Python function' .format (func ))
21352135
2136+ s = getattr (func , "__text_signature__" , None )
2137+ if s :
2138+ return _signature_fromstr (cls , func , s , skip_bound_arg )
2139+
21362140 Parameter = cls ._parameter_cls
21372141
21382142 # Parameter information.
@@ -2301,7 +2305,8 @@ def _signature_from_callable(obj, *,
23012305 if isfunction (obj ) or _signature_is_functionlike (obj ):
23022306 # If it's a pure Python function, or an object that is duck type
23032307 # of a Python function (Cython functions, for instance), then:
2304- return _signature_from_function (sigcls , obj )
2308+ return _signature_from_function (sigcls , obj ,
2309+ skip_bound_arg = skip_bound_arg )
23052310
23062311 if _signature_is_builtin (obj ):
23072312 return _signature_from_builtin (sigcls , obj ,
0 commit comments