def deprecate ( func ) : @ wraps ( func ) def wrapper ( * args , * * kwargs ) : warn ( "Deprecated, this will be removed in the future" , DeprecationWarning ) return func ( * args , * * kwargs ) wrapper . __doc__ = "Deprecated.\n" + ( wrapper . __doc__ or "" ) return wrapper
how to deprecate function in python
A deprecation warning emmiter as a decorator .
def deprecate(func):
  """ A deprecation warning emmiter as a decorator. """
  @wraps(func)
  def wrapper(*args, **kwargs):
    warn("Deprecated, this will be removed in the future", DeprecationWarning)
    return func(*args, **kwargs)
  wrapper.__doc__ = "Deprecated.\n" + (wrapper.__doc__ or "")
  return wrapper