def returns_typeclass(method):
 def func(self, *args, **kwargs):
  self.__doc__ = method.__doc__
  query = method(self, *args, **kwargs)
  if hasattr(query, '__iter__'):
   result = list(query)
   return (result[0] if result else None)
  else:
   return query
 return update_wrapper(func, method)

def returns_typeclass ( method ) : def func ( self , * args , ** kwargs ) : self . __doc__ = method . __doc__ query = method ( self , * args , ** kwargs ) if hasattr ( query , '__iter__' ) : result = list ( query ) return ( result [ 0 ] if result else None ) else : return query return update_wrapper ( func , method )
decorator: returns a single typeclass match or none .