def is_bool_dtype(arr_or_dtype):
if arr_or_dtype is None:<EOL><INDENT>return False<EOL><DEDENT>try:<EOL><INDENT>dtype = _get_dtype(arr_or_dtype)<EOL><DEDENT>except TypeError:<EOL><INDENT>return False<EOL><DEDENT>if isinstance(arr_or_dtype, CategoricalDtype):<EOL><INDENT>arr_or_dtype = arr_or_dtype.categories<EOL><DEDENT>if isinstance(arr_or_dtype, ABCIndexClass):<EOL><INDENT>return (arr_or_dtype.is_object and<EOL>arr_or_dtype.inferred_type == '<STR_LIT>')<EOL><DEDENT>elif is_extension_array_dtype(arr_or_dtype):<EOL><INDENT>dtype = getattr(arr_or_dtype, '<STR_LIT>', arr_or_dtype)<EOL>return dtype._is_boolean<EOL><DEDENT>return issubclass(dtype.type, np.bool_)<EOL>
Check whether the provided array or dtype is of a boolean dtype.

Parameters
----------
arr_or_dtype : array-like
    The array or dtype to check.

Returns
-------
boolean
    Whether or not the array or dtype is of a boolean dtype.

Notes
-----
An ExtensionArray is considered boolean when the ``_is_boolean``
attribute is set to True.

Examples
--------
>>> is_bool_dtype(str)
False
>>> is_bool_dtype(int)
False
>>> is_bool_dtype(bool)
True
>>> is_bool_dtype(np.bool)
True
>>> is_bool_dtype(np.array(['a', 'b']))
False
>>> is_bool_dtype(pd.Series([1, 2]))
False
>>> is_bool_dtype(np.array([True, False]))
True
>>> is_bool_dtype(pd.Categorical([True, False]))
True
>>> is_bool_dtype(pd.SparseArray([True, False]))
True