Show More
@@ -21,6 +21,7 b' import itertools' | |||
|
21 | 21 | import functools |
|
22 | 22 | import re |
|
23 | 23 | import types |
|
24 | import inspect | |
|
24 | 25 | |
|
25 | 26 | |
|
26 | 27 | # patch for single-file |
@@ -71,7 +72,7 b' def signature(obj):' | |||
|
71 | 72 | if not callable(obj): |
|
72 | 73 | raise TypeError('{0!r} is not a callable object'.format(obj)) |
|
73 | 74 | |
|
74 | if isinstance(obj, types.MethodType): | |
|
75 | if inspect.ismethod(obj): | |
|
75 | 76 | if obj.__self__ is None: |
|
76 | 77 | # Unbound method - treat it as a function (no distinction in Py 3) |
|
77 | 78 | obj = obj.__func__ |
@@ -96,7 +97,7 b' def signature(obj):' | |||
|
96 | 97 | else: |
|
97 | 98 | return signature(wrapped) |
|
98 | 99 | |
|
99 | if isinstance(obj, types.FunctionType): | |
|
100 | if inspect.isfunction(obj): | |
|
100 | 101 | return Signature.from_function(obj) |
|
101 | 102 | |
|
102 | 103 | if isinstance(obj, functools.partial): |
@@ -511,7 +512,7 b' class Signature(object):' | |||
|
511 | 512 | def from_function(cls, func): |
|
512 | 513 | '''Constructs Signature for the given python function''' |
|
513 | 514 | |
|
514 |
if not i |
|
|
515 | if not inspect.isfunction(func): | |
|
515 | 516 | raise TypeError('{0!r} is not a Python function'.format(func)) |
|
516 | 517 | |
|
517 | 518 | Parameter = cls._parameter_cls |
General Comments 0
You need to be logged in to leave comments.
Login now