How to use the questionary.utils.missing_arguments function in questionary

To help you get started, we’ve selected a few questionary examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tmbo / questionary / tests / test_utils.py View on Github external
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()
github tmbo / questionary / tests / test_utils.py View on Github external
def test_missing_arguments_of_no_args():
    def f():
        pass

    defaults = utils.missing_arguments(f, {})
    assert defaults == set()
github tmbo / questionary / questionary / prompt.py View on Github external
"'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)
                        )