Skip to content

Commit

Permalink
Un-deprecate sphinx.util.import_object (#13330)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
  • Loading branch information
mgeier and AA-Turner authored Feb 11, 2025
1 parent 9069005 commit 94563a3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Deprecated

* #13037: Deprecate the ``SingleHTMLBuilder.fix_refuris`` method.
Patch by James Addison.
* #13083, #13330: Un-deprecate ``sphinx.util.import_object``.
Patch by Matthias Geier.

Features added
--------------
Expand Down
5 changes: 0 additions & 5 deletions doc/extdev/deprecated.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ The following is a list of deprecated interfaces.
- 10.0
- N/A

* - ``sphinx.util.import_object``
- 8.1
- 10.0
- ``importlib.import_module``

* - ``sphinx.ext.intersphinx.normalize_intersphinx_mapping``
- 8.0
- 10.0
Expand Down
11 changes: 5 additions & 6 deletions sphinx/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ def __getattr__(name: str) -> Any:
_deprecation_warning(__name__, name, '', remove=(10, 0))
return obj

if name == 'import_object':
from sphinx.util._importer import import_object

_deprecation_warning(__name__, name, '', remove=(10, 0))
return import_object

# Re-exported for backwards compatibility,
# but not currently deprecated

Expand All @@ -112,6 +106,11 @@ def __getattr__(name: str) -> Any:

return encode_uri

if name == 'import_object':
from sphinx.util._importer import import_object

return import_object

if name == 'isurl':
from sphinx.util._uri import is_url

Expand Down
3 changes: 1 addition & 2 deletions tests/test_util/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,11 @@ def test_exported_attributes():
assert sphinx.util.FilenameUniqDict is FilenameUniqDict
with pytest.warns(RemovedInSphinx10Warning, match=r'deprecated.'):
assert sphinx.util.DownloadFiles is DownloadFiles
with pytest.warns(RemovedInSphinx10Warning, match=r'deprecated.'):
assert sphinx.util.import_object is import_object

# Re-exported for backwards compatibility,
# but not currently deprecated
assert sphinx.util.encode_uri is encode_uri
assert sphinx.util.import_object is import_object
assert sphinx.util.isurl is is_url
assert sphinx.util.parselinenos is parse_line_num_spec
assert sphinx.util.patfilter is patfilter
Expand Down

0 comments on commit 94563a3

Please # to comment.