def to_cli_filter(bool_or_filter):
    if not isinstance(bool_or_filter, (bool, CLIFilter)):
        raise TypeError('Expecting a bool or a CLIFilter instance. Got %r' % bool_or_filter)

    return {
        True: _always,
        False: _never,
    }.get(bool_or_filter, bool_or_filter)
Accept both booleans and CLIFilters as input and
dataset/ETHPy150Open jonathanslenders/python-prompt-toolkit/prompt_toolkit/filters/utils.py/to_cli_filter