parameters: (val, filter, dict_factory, retain_collection_types)
return_statement: return rv
docstring: ``asdict`` only works on attrs instances, this works on anything.
docstring_summary: ``asdict`` only works on attrs instances, this works on anything.
docstring_tokens: asdict only works on attrs instances this works on anything .
function: def _asdict_anything(val, filter, dict_factory, retain_collection_types):
      """
      ``asdict`` only works on attrs instances, this works on anything.
      """
      if getattr(val.__class__, "__attrs_attrs__", None) is not None:
          # Attrs class.
          rv = asdict(val, True, filter, dict_factory, retain_collection_types)
      elif isinstance(val, (tuple, list, set)):
          cf = val.__class__ if retain_collection_types is True else list
          rv = cf(
              [
                  _asdict_anything(
                      i, filter, dict_factory, retain_collection_types
                  )
                  for i in val
              ]
          )
      elif isinstance(val, dict):
          df = dict_factory
          rv = df(
              (
                  _asdict_anything(kk, filter, df, retain_collection_types),
                  _asdict_anything(vv, filter, df, retain_collection_types),
              )
              for kk, vv in iteritems(val)
          )
      else:
          rv = val
      return rv
function_tokens: def _asdict_anything ( val , filter , dict_factory , retain_collection_types ) : if getattr ( val . __class__ , "__attrs_attrs__" , None ) is not None : # Attrs class. rv = asdict ( val , True , filter , dict_factory , retain_collection_types ) elif isinstance ( val , ( tuple , list , set ) ) : cf = val . __class__ if retain_collection_types is True else list rv = cf ( [ _asdict_anything ( i , filter , dict_factory , retain_collection_types ) for i in val ] ) elif isinstance ( val , dict ) : df = dict_factory rv = df ( ( _asdict_anything ( kk , filter , df , retain_collection_types ) , _asdict_anything ( vv , filter , df , retain_collection_types ) , ) for kk , vv in iteritems ( val ) ) else : rv = val return rv