mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
Update importlib resources for 3.13 (#12298)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
32
stdlib/@tests/test_cases/check_importlib_resources.py
Normal file
32
stdlib/@tests/test_cases/check_importlib_resources.py
Normal 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)
|
||||
Reference in New Issue
Block a user