def validate_boolean(option, value):
    """Validates that 'value' is True or False."""
    if isinstance(value, bool):
        return value
    raise TypeError("%s must be True or False" % (option,))
Validates that 'value' is True or False.
stackoverflow/venv/lib/python3.6/site-packages/pymongo/common.py