Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_missing_arguments():
def f(a, b=2, c=None, *args, **kwargs):
pass
assert utils.missing_arguments(f, {}) == {"a"}
assert utils.missing_arguments(f, {"a": 1}) == set()
assert utils.missing_arguments(f, {"a": 1, "b": 2}) == set()
def test_missing_arguments_of_no_args():
def f():
pass
defaults = utils.missing_arguments(f, {})
assert defaults == set()
"'filter' needs to be function that " "accepts an argument"
)
if callable(question_config.get("default")):
_kwargs["default"] = question_config["default"](answers)
create_question_func = prompt_by_name(_type)
if not create_question_func:
raise ValueError(
"No question type '{}' found. "
"Known question types are {}."
"".format(_type, ", ".join(AVAILABLE_PROMPTS))
)
missing_args = list(utils.missing_arguments(create_question_func, _kwargs))
if missing_args:
raise PromptParameterException(missing_args[0])
question = create_question_func(**_kwargs)
answer = question.unsafe_ask(patch_stdout)
if answer is not None:
if _filter:
try:
answer = _filter(answer)
except Exception as e:
raise ValueError(
"Problem processing 'filter' of {} "
"question: {}".format(name, e)
)