Skip to content

Remove deprecated parameter alias for importlib.resources.files#138044

@donbarbos

Description

@donbarbos

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-importlibtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions