Merge pull request #7641 from tk0miya/deprecate_rpartition

Deprecate sphinx.util:rpartition()
This commit is contained in:
Takeshi KOMIYA
2020-05-09 22:34:15 +09:00
committed by GitHub
4 changed files with 10 additions and 3 deletions

View File

@@ -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
--------------

View File

@@ -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

View File

@@ -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]

View File

@@ -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):]