Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
Deserialize a (JSON) dict into a mapping by deserializing all items of that
dict.
:param obj: the dict that needs deserializing.
:param cls: the type, optionally with a generic (e.g. Set[str]).
:param kwargs: any keyword arguments.
:return: a deserialized set instance.
"""
cls_ = Mapping
cls_args = get_args(cls)
if cls_args:
cls_ = MappingType[cls_args]
dict_ = default_dict_deserializer(obj, cls_, **kwargs)
result = dict_
# Strip any generics from cls to allow for an instance check.
if not isinstance(result, get_origin(cls)):
result = cls(dict_)
return result