Add deprecated-removed directive to Sphinx (#4912)

* Add `deprecated-removed` directive to Sphinx

* Add equivalent function to internal utils
This commit is contained in:
jack1142
2021-04-03 18:48:17 +02:00
committed by GitHub
parent 76bb65912e
commit 0144cbf88b
3 changed files with 149 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ import os
import re
import shutil
import tarfile
import warnings
from datetime import datetime
from pathlib import Path
from typing import (
@@ -46,6 +47,7 @@ __all__ = (
"send_to_owners_with_prefix_replaced",
"expected_version",
"fetch_latest_red_version_info",
"deprecated_removed",
)
@@ -317,3 +319,19 @@ async def fetch_latest_red_version_info() -> Tuple[Optional[VersionInfo], Option
required_python = data["info"]["requires_python"]
return release, required_python
def deprecated_removed(
deprecation_target: str,
deprecation_version: str,
minimum_days: int,
message: str = "",
stacklevel: int = 1,
) -> None:
warnings.warn(
f"{deprecation_target} is deprecated since version {deprecation_version}"
" and will be removed in the first minor version that gets released"
f" after {minimum_days} days since deprecation. {message}",
DeprecationWarning,
stacklevel=stacklevel + 1,
)