"""Utils for checking objects."""
from beartype import beartype
[docs]
def is_primitive(val: object) -> bool:
"""Check an object if it's a primitive object.
:param val: Any instance for checking.
:return:
* :obj:`True` -- If the object is primitive
* :obj:`False` -- Otherwise.
"""
return isinstance(val, (str, int, float, bool)) or val is None
[docs]
@beartype
def is_nested_dict(obj: dict) -> bool:
"""Check a dict if it has nested structures.
:param obj: Any dict object for checking.
:return:
* :obj:`True` -- If the dict has nested structures.
* :obj:`False` -- Otherwise.
"""
for k, v in obj.items():
if not is_primitive(v):
return True
return False