is_tuple#
- paramcheckup.types.is_tuple(value, param_name, kind, kind_name, stacklevel=4, error=True)[source]#
This function checks whether a variable value is of the tuple type.
- Parameters:
- valueany type
The variable that is tested as being of type tuple ;
- 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 variable value IS of the tuple type;
- raisesTypeError
If variable value is NOT of the tuple type;
Examples
>>> from paramcheckup import types >>> output = types.is_tuple( value=(0.345, 0.348, 0.401), param_name="critical", kind="function", kind_name="get_critical", stacklevel=3, error=True, ) >>> print(output) True
>>> from paramcheckup import types >>> output = types.is_tuple( value=[0.345, 0.348, 0.401], param_name="critical", kind="function", kind_name="get_critical", stacklevel=3, error=False, ) UserWarning at line 2: The parameter `critical` in function `get_critical` must be of type `tuple`, but its type is `list`.