def _deprecated_method(old_name, new_name, version):
    """Create a deprecated method wrapper for a deprecated method name"""

    def deprecated(self, *args, **kwargs):
        warnings.warn(
            (
                f"{self.__class__.__name__}.{old_name} is deprecated in JupyterHub {version}."
                f" Please use {self.__class__.__name__}.{new_name} instead."
            ),
            DeprecationWarning,
            stacklevel=2,
        )
        old_method = getattr(self, new_name)
        return old_method(*args, **kwargs)

    return deprecated
Create a deprecated method wrapper for a deprecated method name
jupyterhub/auth.py