diff --git a/CHANGES b/CHANGES index 14534b096..b6f8a8d5f 100644 --- a/CHANGES +++ b/CHANGES @@ -27,6 +27,7 @@ Deprecated generate_autosummary_docs()`` * The ``ignore`` argument of ``sphinx.util.docstring.prepare_docstring()`` * ``sphinx.ext.autosummary.generate.AutosummaryRenderer.exists()`` +* ``sphinx.util.rpartition()`` Features added -------------- diff --git a/doc/extdev/deprecated.rst b/doc/extdev/deprecated.rst index 9d05f894b..7e59184ec 100644 --- a/doc/extdev/deprecated.rst +++ b/doc/extdev/deprecated.rst @@ -78,6 +78,11 @@ The following is a list of deprecated interfaces. - 5.0 - N/A + * - ``sphinx.util.rpartition()`` + - 3.1 + - 5.0 + - ``str.rpartition()`` + * - ``desc_signature['first']`` - - 3.0 diff --git a/sphinx/search/__init__.py b/sphinx/search/__init__.py index f9bbe0590..74fbaade9 100644 --- a/sphinx/search/__init__.py +++ b/sphinx/search/__init__.py @@ -23,7 +23,7 @@ from sphinx import package_dir from sphinx.deprecation import RemovedInSphinx40Warning from sphinx.environment import BuildEnvironment from sphinx.search.jssplitter import splitter_code -from sphinx.util import jsdump, rpartition +from sphinx.util import jsdump if False: # For type annotation @@ -333,7 +333,7 @@ class IndexBuilder: continue fullname = html.escape(fullname) dispname = html.escape(dispname) - prefix, name = rpartition(dispname, '.') + prefix, _, name = dispname.rpartition('.') pdict = rv.setdefault(prefix, {}) try: typeindex = otypes[domainname, type] diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index 66f5fe060..ca9bb028d 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -28,7 +28,7 @@ from time import mktime, strptime from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Pattern, Set, Tuple from urllib.parse import urlsplit, urlunsplit, quote_plus, parse_qsl, urlencode -from sphinx.deprecation import RemovedInSphinx40Warning +from sphinx.deprecation import RemovedInSphinx40Warning, RemovedInSphinx50Warning from sphinx.errors import ( PycodeError, SphinxParallelError, ExtensionError, FiletypeNotFoundError ) @@ -497,6 +497,7 @@ class attrdict(dict): def rpartition(s: str, t: str) -> Tuple[str, str]: """Similar to str.rpartition from 2.5, but doesn't return the separator.""" + warnings.warn('rpartition() is now deprecated.', RemovedInSphinx50Warning, stacklevel=2) i = s.rfind(t) if i != -1: return s[:i], s[i + len(t):]