Argument name was replaced from package to anchor for Python 3.12.0a4 in PR #100598, and comment to remove this compatibility was added separately in PR #117054, both by @jaraco.
Looks like it was missed so I suggest to remove this compatibility.
Docs: https://docs.python.org/dev/library/importlib.resources.html#importlib.resources.files
Source:
| defpackage_to_anchor(func): |
| """ |
| Replace 'package' parameter as 'anchor' and warn about the change. |
| |
| Other errors should fall through. |
| |
| >>> files('a', 'b') |
| Traceback (most recent call last): |
| TypeError: files() takes from 0 to 1 positional arguments but 2 were given |
| |
| Remove this compatibility in Python 3.14. |
| """ |
| undefined=object() |
| |
| @functools.wraps(func) |
| defwrapper(anchor=undefined, package=undefined): |
| ifpackageisnotundefined: |
| ifanchorisnotundefined: |
| returnfunc(anchor, package) |
| warnings.warn( |
| "First parameter to files is renamed to 'anchor'", |
| DeprecationWarning, |
| stacklevel=2, |
| ) |
| returnfunc(package) |
| elifanchorisundefined: |
| returnfunc() |
| returnfunc(anchor) |
| |
| returnwrapper |
| |
| |
| @package_to_anchor |
| deffiles(anchor: Optional[Anchor] =None) ->Traversable: |
| """ |
| Get a Traversable resource for an anchor. |
| """ |
| returnfrom_package(resolve(anchor)) |
Linked PRs
Argument name was replaced from
packagetoanchorfor Python3.12.0a4in PR #100598, and comment to remove this compatibility was added separately in PR #117054, both by @jaraco.Looks like it was missed so I suggest to remove this compatibility.
Docs: https://docs.python.org/dev/library/importlib.resources.html#importlib.resources.files
Source:
cpython/Lib/importlib/resources/_common.py
Lines 19 to 56 in 5a7f5ea
Linked PRs
importlib.resources.files#138059importlib.resources.filesdeprecation docs #139632