Update `sphinx.deprecation` for Sphinx 7.0 (#11386)

This commit is contained in:
Adam Turner
2023-04-28 12:10:13 +01:00
committed by GitHub
parent 6202087f91
commit 5795fc7f9f
+10 -10
View File
@@ -5,15 +5,15 @@ from __future__ import annotations
import warnings
class RemovedInSphinx70Warning(DeprecationWarning):
class RemovedInSphinx80Warning(DeprecationWarning):
pass
class RemovedInSphinx80Warning(PendingDeprecationWarning):
class RemovedInSphinx90Warning(PendingDeprecationWarning):
pass
RemovedInNextVersionWarning = RemovedInSphinx70Warning
RemovedInNextVersionWarning = RemovedInSphinx80Warning
def _deprecation_warning(
@@ -31,7 +31,7 @@ def _deprecation_warning(
# deprecated name -> (object to return, canonical path or empty string)
_DEPRECATED_OBJECTS = {
'deprecated_name': (object_to_return, 'fully_qualified_replacement_name'),
'deprecated_name': (object_to_return, 'fully_qualified_replacement_name', (8, 0)),
}
@@ -41,15 +41,15 @@ def _deprecation_warning(
from sphinx.deprecation import _deprecation_warning
deprecated_object, canonical_name = _DEPRECATED_OBJECTS[name]
_deprecation_warning(__name__, name, canonical_name, remove=(7, 0))
deprecated_object, canonical_name, remove = _DEPRECATED_OBJECTS[name]
_deprecation_warning(__name__, name, canonical_name, remove=remove)
return deprecated_object
"""
if remove == (7, 0):
warning_class: type[Warning] = RemovedInSphinx70Warning
elif remove == (8, 0):
warning_class = RemovedInSphinx80Warning
if remove == (8, 0):
warning_class: type[Warning] = RemovedInSphinx80Warning
elif remove == (9, 0):
warning_class = RemovedInSphinx90Warning
else:
raise RuntimeError(f'removal version {remove!r} is invalid!')