Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sphinx.deprecation for Sphinx 7.0 #11386

Merged
merged 2 commits into from Apr 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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