try:

            ret['type'] = val[1]['type']

        except (KeyError, ValueError, TypeError):