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