Skip to content

Commit

Permalink
Update sphinx.deprecation for Sphinx 7.0 (#11386)
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Apr 28, 2023
1 parent 6202087 commit 5795fc7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions sphinx/deprecation.py
Expand Up @@ -5,15 +5,15 @@
import warnings


class RemovedInSphinx70Warning(DeprecationWarning):
class RemovedInSphinx80Warning(DeprecationWarning):
pass


class RemovedInSphinx80Warning(PendingDeprecationWarning):
class RemovedInSphinx90Warning(PendingDeprecationWarning):
pass


RemovedInNextVersionWarning = RemovedInSphinx70Warning
RemovedInNextVersionWarning = RemovedInSphinx80Warning


def _deprecation_warning(
Expand All @@ -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)),
}
Expand All @@ -41,15 +41,15 @@ def __getattr__(name):
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!')

Expand Down

0 comments on commit 5795fc7

Please sign in to comment.