Al-HUWAITI Shell
Al-huwaiti


Server : LiteSpeed
System : Linux in-mum-web1112.main-hosting.eu 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64
User : u451330669 ( 451330669)
PHP Version : 8.2.27
Disable Function : NONE
Directory :  /opt/alt/python311/lib/python3.11/site-packages/jsons/deserializers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/alt/python311/lib/python3.11/site-packages/jsons/deserializers/default_iterable.py
from collections.abc import Mapping, Iterable
from typing import Iterable as IterableType

from jsons._compatibility_impl import get_naked_class
from jsons.deserializers.default_list import default_list_deserializer


def default_iterable_deserializer(
        obj: list,
        cls: type,
        **kwargs) -> Iterable:
    """
    Deserialize a (JSON) list into an ``Iterable`` by deserializing all items
    of that list. The given obj is assumed to be homogeneous; if the list has a
    generic type (e.g. Set[datetime]) then it is assumed that all elements can
    be deserialized to that type.
    :param obj: The list that needs deserializing to an ``Iterable``.
    :param cls: The type, optionally with a generic (e.g. Deque[str]).
    :param kwargs: Any keyword arguments.
    :return: A deserialized ``Iterable`` (e.g. ``set``) instance.
    """
    cls_ = Mapping
    if hasattr(cls, '__args__'):
        cls_ = IterableType[cls.__args__]
    list_ = default_list_deserializer(obj, cls_, **kwargs)
    result = list_
    naked_cls = get_naked_class(cls)
    if not isinstance(result, naked_cls):
        result = naked_cls(list_)
    return result

Al-HUWAITI Shell