Skip to content

Commit e41586e

Browse files
author
Ryan P Kilby
committed
Check args and kwargs in is_simple_callable
1 parent 91d6fb1 commit e41586e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

rest_framework/fields.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,17 @@ def is_simple_callable(obj):
5454
"""
5555
True if the object is a callable that takes no arguments.
5656
"""
57-
if not callable(obj):
57+
if not inspect.isfunction(obj) or inspect.ismethod(obj):
5858
return False
5959

6060
sig = inspect.signature(obj)
6161
params = sig.parameters.values()
62-
return all(param.default != param.empty for param in params)
62+
return all(
63+
param.kind == param.VAR_POSITIONAL or
64+
param.kind == param.VAR_KEYWORD or
65+
param.default != param.empty
66+
for param in params
67+
)
6368

6469
else:
6570
def is_simple_callable(obj):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy