How to use the typish.get_type function in typish

To help you get started, we’ve selected a few typish examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ramonhagenaars / jsons / jsons / serializers / default_object.py View on Github external
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
github ramonhagenaars / jsons / jsons / serializers / default_dict.py View on Github external
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
github ramonhagenaars / jsons / jsons / serializers / default_iterable.py View on Github external
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_