code: def _new_name(method, old_name):
      
      # Looks suspiciously like a decorator, but isn't!
  
      @wraps(method)
      def _method(*args, **kwargs):
          warnings.warn(
              "method '{}' has been deprecated, please rename to '{}'".format(
                  old_name, method.__name__
              ),
              DeprecationWarning,
          )
          return method(*args, **kwargs)
  
      deprecated_msg = """
          Note:
              .. deprecated:: 2.2.0
                  Please use `~{}`
  """.format(
          method.__name__
      )
      if getattr(_method, "__doc__"):
          _method.__doc__ += deprecated_msg
  
      return _method
docs: Return a method with a deprecation warning.