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:
|
def package_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) |
|
def wrapper(anchor=undefined, package=undefined): |
|
if package is not undefined: |
|
if anchor is not undefined: |
|
return func(anchor, package) |
|
warnings.warn( |
|
"First parameter to files is renamed to 'anchor'", |
|
DeprecationWarning, |
|
stacklevel=2, |
|
) |
|
return func(package) |
|
elif anchor is undefined: |
|
return func() |
|
return func(anchor) |
|
|
|
return wrapper |
|
|
|
|
|
@package_to_anchor |
|
def files(anchor: Optional[Anchor] = None) -> Traversable: |
|
""" |
|
Get a Traversable resource for an anchor. |
|
""" |
|
return from_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