PendingDeprecationWarning is really useful?

Just so people know what I have thought about, I’ve contemplated adding the following to warnings:

def _deprecate(message, *, remove, start=None, stacklevel=2):
    """Deprecate starting in the Python version 'start' and remove in 'remove'.

    Both 'start' and 'remove' are two-item tuples representing a (major, minor)
    version of Python. If 'start' is specified, then the >N-1 version of 'remove'
    will raise PendingDeprecationWarning, otherwise DeprecationWarning is
    raised for >N of 'remove'. When the Python version <= 'remove' then XXX.
    """

I don’t know if some other warning should be raised once remove is reached or raise an exception.

I’m also tempted to provide a way to have a template message for the warning since most are of the form f"{name} has been deprecated since {start} and is slated for removal in {remove}; use {alternative} instead" (with obvious tweaks based on what is provided in the function call).

4 Likes