def typechain(*args):
 if (len(args) == 0):
  raise TypeError('No arguments were provided.')
 def annotation(value):
  '\n        Returns value either transformed with one of the function in args, or\n        casted to one of types in args, or the value itself if it is in the\n        args.\n\n        :raises ValueError: Raises when cannot transform value in any one of\n                            specified ways.\n        '
  for arg in args:
   if (value == arg):
    return value
   if (isinstance(arg, type) and isinstance(value, arg)):
    return value
   try:
    return arg(value)
   except (ValueError, TypeError):
    pass
  raise ValueError("Couldn't convert value {!r} to any specified type or find it in specified values.".format(value))
 return annotation

def typechain ( * args ) : if ( len ( args ) == 0 ) : raise TypeError ( 'No arguments were provided.' ) def annotation ( value ) : for arg in args : if ( value == arg ) : return value if ( isinstance ( arg , type ) and isinstance ( value , arg ) ) : return value try : return arg ( value ) except ( ValueError , TypeError ) : pass raise ValueError ( "Couldn't convert value {!r} to any specified type or find it in specified values." . format ( value ) ) return annotation
returns function which applies the first transformation it can from args and returns transformed value .