mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-08 06:14:47 +03:00
Merge 343b055ba7
into d404597e0b
This commit is contained in:
commit
11a1c5419b
|
@ -58,10 +58,18 @@ def is_simple_callable(obj):
|
||||||
if not (function or method):
|
if not (function or method):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
args, _, _, defaults = inspect.getargspec(obj)
|
if six.PY2:
|
||||||
len_args = len(args) if function else len(args) - 1
|
args, _, _, defaults = inspect.getargspec(obj)
|
||||||
len_defaults = len(defaults) if defaults else 0
|
len_args = len(args) if function else len(args) - 1
|
||||||
return len_args <= len_defaults
|
len_defaults = len(defaults) if defaults else 0
|
||||||
|
return len_args <= len_defaults
|
||||||
|
else:
|
||||||
|
sig = inspect.signature(obj)
|
||||||
|
for name, param in sig.parameters.items():
|
||||||
|
if param.default is not inspect.Parameter.empty:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def get_attribute(instance, attrs):
|
def get_attribute(instance, attrs):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user