Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _store_cls_info(result: object, original_obj: dict, kwargs):
if kwargs.get('_store_cls', None) and isinstance(result, dict):
cls = get_type(original_obj)
if cls.__module__ == 'typing':
cls_name = repr(cls)
else:
cls_name = get_class_name(cls, fully_qualified=True)
result['-cls'] = cls_name
def _store_cls_info(result: object, attr: str, original_obj: dict, **kwargs):
if isinstance(result, dict) and kwargs.get('_store_cls'):
cls = get_type(original_obj[attr])
if cls.__module__ == 'typing':
cls_name = repr(cls)
else:
cls_name = get_class_name(cls, fully_qualified=True,
fork_inst=kwargs['fork_inst'])
result['-cls'] = cls_name
def determine_cls(obj: Iterable, cls: Optional[type]) -> Optional[type]:
cls_ = cls
if not cls and hasattr(obj, '__getitem__') and len(obj) > 0:
obj_with_only_one_elem = obj.__getitem__(slice(0, 1))
cls_ = get_type(obj_with_only_one_elem)
return cls_