Show More
@@ -72,10 +72,13 b' def signature(obj):' | |||
|
72 | 72 | raise TypeError('{0!r} is not a callable object'.format(obj)) |
|
73 | 73 | |
|
74 | 74 | if isinstance(obj, types.MethodType): |
|
75 | # In this case we skip the first parameter of the underlying | |
|
76 | # function (usually `self` or `cls`). | |
|
77 |
|
|
|
78 | return sig.replace(parameters=tuple(sig.parameters.values())[1:]) | |
|
75 | if obj.__self__ is None: | |
|
76 | # Unbound method - treat it as a function (no distinction in Py 3) | |
|
77 | obj = obj.__func__ | |
|
78 | else: | |
|
79 | # Bound method: trim off the first parameter (typically self or cls) | |
|
80 | sig = signature(obj.__func__) | |
|
81 | return sig.replace(parameters=tuple(sig.parameters.values())[1:]) | |
|
79 | 82 | |
|
80 | 83 | try: |
|
81 | 84 | sig = obj.__signature__ |
General Comments 0
You need to be logged in to leave comments.
Login now