Skip to content

Commit ed3b2d3

Browse files
committed
Add section to the docs guiding the user on how to migrate (relying on the _legacy module as a guide because it's so easy to read).
1 parent fda6cb2 commit ed3b2d3

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

CHANGES.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ v5.3.0
33

44
* #80: Now raise a ``DeprecationWarning`` for all legacy
55
functions. Instead, users should rely on the ``files()``
6-
API introduced in importlib_resources 1.3.
6+
API introduced in importlib_resources 1.3. See
7+
`Migrating from Legacy <https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy>`_
8+
for guidance on avoiding the deprecated functions.
79

810
v5.2.3
911
======

docs/using.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,21 @@ manager.
163163
Both relative and absolute paths work for Python 3.7 and newer.
164164

165165

166+
Migrating from Legacy
167+
=====================
168+
169+
Starting with Python 3.9 and ``importlib_resources`` 1.4, this package
170+
introduced the ``files()`` API, to be preferred over the legacy API,
171+
i.e. the functions ``open_binary``, ``open_text``, ``path``,
172+
``contents``, ``read_text``, ``read_binary``, and ``is_resource``.
173+
174+
To port to the ``files()`` API, refer to the
175+
`_legacy module <https://github.com/python/importlib_resources/blob/66ea2dc7eb12b1be2322b7ad002cefb12d364dff/importlib_resources/_legacy.py>`_
176+
to see simple wrappers that enable drop-in replacement based on the
177+
preferred API, and either copy those or adapt the usage to utilize the
178+
``files`` and ``Traversable`` interfaces directly.
179+
180+
166181
Extending
167182
=========
168183

0 commit comments

Comments
 (0)