Commit 367909e2 by Tom Christie

Merge pull request #657 from dgaus/master

Make is_simple_callable consider default arguments
parents 6dd867c8 40b13a86
...@@ -25,10 +25,14 @@ def is_simple_callable(obj): ...@@ -25,10 +25,14 @@ def is_simple_callable(obj):
""" """
True if the object is a callable that takes no arguments. True if the object is a callable that takes no arguments.
""" """
return ( try:
(inspect.isfunction(obj) and not inspect.getargspec(obj)[0]) or args, _, _, defaults = inspect.getargspec(obj)
(inspect.ismethod(obj) and len(inspect.getargspec(obj)[0]) <= 1) except TypeError:
) return False
else:
len_args = len(args) if inspect.isfunction(obj) else len(args) - 1
len_defaults = len(defaults) if defaults else 0
return len_args <= len_defaults
def get_component(obj, attr_name): def get_component(obj, attr_name):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment