MCPcopy
hub / github.com/celery/celery / fun_accepts_kwargs

Function fun_accepts_kwargs

celery/utils/functional.py:400–411  ·  view source on GitHub ↗

Return true if function accepts arbitrary keyword arguments.

(fun)

Source from the content-addressed store, hash-verified

398
399
400def fun_accepts_kwargs(fun):
401 """Return true if function accepts arbitrary keyword arguments."""
402 # inspect.signature evaluates annotations in Python 3.14+ (PEP 649),
403 # which raises NameError for types only imported under TYPE_CHECKING.
404 # Check co_flags directly to avoid touching annotations entirely.
405 code = getattr(fun, '__code__', None)
406 if code is not None:
407 return bool(code.co_flags & inspect.CO_VARKEYWORDS)
408 return any(
409 p for p in inspect.signature(fun).parameters.values()
410 if p.kind == p.VAR_KEYWORD
411 )
412
413
414def maybe(typ, val):

Callers 4

test_acceptsMethod · 0.90
test_rejectsMethod · 0.90
_connect_signalMethod · 0.90

Calls 1

signatureMethod · 0.45

Tested by 3

test_acceptsMethod · 0.72
test_rejectsMethod · 0.72