Skip to content

Commit f1a6988

Browse files
authored
Merge pull request #333 from python/debt/alias
gh-138044: Remove deprecated parameter alias for `importlib.resources.files` (python/cpython#138059)
2 parents b1d2187 + e406447 commit f1a6988

File tree

3 files changed

+2
-42
lines changed

3 files changed

+2
-42
lines changed

importlib_resources/_common.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import pathlib
88
import tempfile
99
import types
10-
import warnings
1110
from typing import Optional, cast
1211

1312
from .abc import ResourceReader, Traversable
@@ -16,39 +15,6 @@
1615
Anchor = Package
1716

1817

19-
def package_to_anchor(func):
20-
"""
21-
Replace 'package' parameter as 'anchor' and warn about the change.
22-
23-
Other errors should fall through.
24-
25-
>>> files('a', 'b')
26-
Traceback (most recent call last):
27-
TypeError: files() takes from 0 to 1 positional arguments but 2 were given
28-
29-
Remove this compatibility in Python 3.14.
30-
"""
31-
undefined = object()
32-
33-
@functools.wraps(func)
34-
def wrapper(anchor=undefined, package=undefined):
35-
if package is not undefined:
36-
if anchor is not undefined:
37-
return func(anchor, package)
38-
warnings.warn(
39-
"First parameter to files is renamed to 'anchor'",
40-
DeprecationWarning,
41-
stacklevel=2,
42-
)
43-
return func(package)
44-
elif anchor is undefined:
45-
return func()
46-
return func(anchor)
47-
48-
return wrapper
49-
50-
51-
@package_to_anchor
5218
def files(anchor: Optional[Anchor] = None) -> Traversable:
5319
"""
5420
Get a Traversable resource for an anchor.

importlib_resources/tests/test_files.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ def test_joinpath_with_multiple_args(self):
3939
binfile = files.joinpath('subdirectory', 'binary.file')
4040
self.assertTrue(binfile.is_file())
4141

42-
def test_old_parameter(self):
43-
"""
44-
Files used to take a 'package' parameter. Make sure anyone
45-
passing by name is still supported.
46-
"""
47-
with suppress_known_deprecation():
48-
resources.files(package=self.data)
49-
5042

5143
class OpenDiskTests(FilesTests, util.DiskSetup, unittest.TestCase):
5244
pass

newsfragments/332.removal.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove compatibility shim for deprecated parameter *package* in
2+
:func:`importlib.resources.files`. Patch by Semyon Moroz.

0 commit comments

Comments
 (0)