is_bool#

paramcheckup.types.is_bool(value, param_name, kind, kind_name, stacklevel=4, error=True)[source]#

This function checks whether a variable value is of the bool type.

Parameters:
valueany type

The variable that is tested as being of type bool;

param_namestr

The name of the parameter that received the variable value;

kindstr

The object where param_name is applied (function, method, class, etc.);

kind_namestr

The name of the object kind;

stacklevelint, optional

The stacking level (default is 4);

errorbool, optional

Whether to display error text (True, default) or not (False);

Returns:
outputTrue

If value IS of the bool type;

raisesTypeError

If value is NOT of the bool type;

Examples

>>> from paramcheckup import types
>>> result = types.is_bool(
    value=True,
    param_name="show",
    kind="function",
    kind_name="plot",
    stacklevel=3,
    error=True,
)
>>> print(result)
True
>>> from paramcheckup import types
>>> result = types.is_bool(
    value="ok",
    param_name="show",
    kind="function",
    kind_name="plot",
    stacklevel=3,
    error=False,
)
UserWarning at line 2: The parameter `show` in function `plot` must be of type `bool`, but its type is `str`.