MCPcopy
hub / github.com/scrapy/scrapy / argument_is_required

Function argument_is_required

scrapy/utils/deprecate.py:203–222  ·  view source on GitHub ↗

Check if a function argument is required (exists and doesn't have a default value). .. versionadded:: 2.14 >>> def func(a, b=1, c=None): ... pass >>> argument_is_required(func, 'a') True >>> argument_is_required(func, 'b') False >>> argument_is_required(fun

(func: Callable[..., Any], arg_name: str)

Source from the content-addressed store, hash-verified

201
202
203def argument_is_required(func: Callable[..., Any], arg_name: str) -> bool:
204 """
205 Check if a function argument is required (exists and doesn't have a default value).
206
207 .. versionadded:: 2.14
208
209 >>> def func(a, b=1, c=None):
210 ... pass
211 >>> argument_is_required(func, 'a')
212 True
213 >>> argument_is_required(func, 'b')
214 False
215 >>> argument_is_required(func, 'c')
216 False
217 >>> argument_is_required(func, 'd')
218 False
219 """
220 args = get_func_args_dict(func)
221 param = args.get(arg_name)
222 return param is not None and param.default is inspect.Parameter.empty
223
224
225def warn_on_deprecated_spider_attribute(attribute_name: str, setting_name: str) -> None:

Callers 4

__init__Method · 0.90
open_spider_asyncMethod · 0.90
close_spider_asyncMethod · 0.90

Calls 2

get_func_args_dictFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected