Update importlib resources for 3.13 (#12298)

This commit is contained in:
Max Muoto
2024-09-16 13:21:35 -05:00
committed by GitHub
parent 94889897ca
commit 85121de466
8 changed files with 155 additions and 29 deletions

View File

@@ -164,6 +164,9 @@ platform.uname_result.processor
unittest.TestCase.__init_subclass__
unittest.case.TestCase.__init_subclass__
# Deprecated argument is supported at runtime by renaming it through a decorator.
importlib.resources._common.files
importlib.resources.files
# Problematic protocol signature at runtime, see source code comments.
importlib.abc.Traversable.open
importlib.resources.abc.Traversable.open

View File

@@ -4,16 +4,6 @@
# TODO: triage these new errors
_tkinter.create
importlib.resources.Anchor
importlib.resources.Resource
importlib.resources.__all__
importlib.resources.contents
importlib.resources.is_resource
importlib.resources.open_binary
importlib.resources.open_text
importlib.resources.path
importlib.resources.read_binary
importlib.resources.read_text
os.path.splitroot
tkinter.Misc.after_info
tkinter.Misc.busy
@@ -151,6 +141,9 @@ platform.uname_result.processor
unittest.TestCase.__init_subclass__
unittest.case.TestCase.__init_subclass__
# Deprecated argument is supported at runtime by renaming it through a decorator.
importlib.resources._common.files
importlib.resources.files
# Problematic protocol signature at runtime, see source code comments.
importlib.abc.Traversable.open
importlib.resources.abc.Traversable.open

View File

@@ -0,0 +1,32 @@
from __future__ import annotations
import importlib.resources
import pathlib
import sys
class _CustomPathLike:
def __fspath__(self) -> str:
return ""
if sys.version_info >= (3, 13):
def f(pth: pathlib.Path | str | _CustomPathLike) -> None:
importlib.resources.open_binary("pkg", pth)
# Encoding defaults to "utf-8" for one arg.
importlib.resources.open_text("pkg", pth)
# Otherwise, it must be specified.
importlib.resources.open_text("pkg", pth, pth) # type: ignore
importlib.resources.open_text("pkg", pth, pth, encoding="utf-8")
# Encoding defaults to "utf-8" for one arg.
importlib.resources.read_text("pkg", pth)
# Otherwise, it must be specified.
importlib.resources.read_text("pkg", pth, pth) # type: ignore
importlib.resources.read_text("pkg", pth, pth, encoding="utf-8")
importlib.resources.read_binary("pkg", pth)
importlib.resources.path("pkg", pth)
importlib.resources.is_resource("pkg", pth)
importlib.resources.contents("pkg", pth)