Skip to content

Commit 6dab4da

Browse files
committed
Fix Python 3.11 support.
1 parent 597495c commit 6dab4da

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

domdf_python_tools/compat/importlib_resources.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,39 @@ def _normalize_path(path: Any) -> str:
3030
raise ValueError(f'{path!r} must be only a file name')
3131
return file_name
3232

33-
def open_binary(package: importlib_resources.Package, resource: importlib_resources.Resource) -> BinaryIO:
33+
def open_binary(package: Package, resource: Resource) -> BinaryIO:
3434
"""
3535
Return a file-like object opened for binary reading of the resource.
3636
"""
3737

38-
return (importlib_resources.files(package) / _normalize_path(resource)).open("rb")
38+
return (files(package) / _normalize_path(resource)).open("rb")
3939

40-
def read_binary(package: importlib_resources.Package, resource: importlib_resources.Resource) -> bytes:
40+
def read_binary(package: Package, resource: Resource) -> bytes:
4141
"""
4242
Return the binary contents of the resource.
4343
"""
4444

45-
return (importlib_resources.files(package) / _normalize_path(resource)).read_bytes()
45+
return (files(package) / _normalize_path(resource)).read_bytes()
4646

4747
def open_text(
48-
package: importlib_resources.Package,
49-
resource: importlib_resources.Resource,
48+
package: Package,
49+
resource: Resource,
5050
encoding: str = "utf-8",
5151
errors: str = "strict",
5252
) -> TextIO:
5353
"""
5454
Return a file-like object opened for text reading of the resource.
5555
"""
5656

57-
return (importlib_resources.files(package) / _normalize_path(resource)).open(
57+
return (files(package) / _normalize_path(resource)).open(
5858
'r',
5959
encoding=encoding,
6060
errors=errors,
6161
)
6262

6363
def read_text(
64-
package: importlib_resources.Package,
65-
resource: importlib_resources.Resource,
64+
package: Package,
65+
resource: Resource,
6666
encoding: str = "utf-8",
6767
errors: str = "strict",
6868
) -> str:

0 commit comments

Comments
 (0)