<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_cli_filter(bool_or_filter):
 """ Accept both booleans and CLIFilters as input and turn it into a CLIFilter. """

    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)