diff --git a/stdlib/importlib/readers.pyi b/stdlib/importlib/readers.pyi index 4a6c73921535..0e7f7ce165c3 100644 --- a/stdlib/importlib/readers.pyi +++ b/stdlib/importlib/readers.pyi @@ -52,9 +52,9 @@ if sys.version_info >= (3, 10): def is_file(self) -> Literal[False]: ... if sys.version_info >= (3, 12): - def joinpath(self, *descendants: str) -> abc.Traversable: ... + def joinpath(self, *descendants: StrPath) -> abc.Traversable: ... elif sys.version_info >= (3, 11): - def joinpath(self, child: str) -> abc.Traversable: ... # type: ignore[override] + def joinpath(self, child: StrPath) -> abc.Traversable: ... # type: ignore[override] else: def joinpath(self, child: str) -> abc.Traversable: ... diff --git a/stdlib/importlib/resources/abc.pyi b/stdlib/importlib/resources/abc.pyi index 80d92a608604..9be594a7dc2f 100644 --- a/stdlib/importlib/resources/abc.pyi +++ b/stdlib/importlib/resources/abc.pyi @@ -1,4 +1,5 @@ import sys +from _typeshed import StrPath from abc import ABCMeta, abstractmethod from collections.abc import Iterator from io import BufferedReader @@ -24,7 +25,7 @@ if sys.version_info >= (3, 11): @abstractmethod def iterdir(self) -> Iterator[Traversable]: ... @abstractmethod - def joinpath(self, *descendants: str) -> Traversable: ... + def joinpath(self, *descendants: StrPath) -> Traversable: ... # The documentation and runtime protocol allows *args, **kwargs arguments, # but this would mean that all implementers would have to support them, @@ -38,7 +39,7 @@ if sys.version_info >= (3, 11): @property @abstractmethod def name(self) -> str: ... - def __truediv__(self, child: str, /) -> Traversable: ... + def __truediv__(self, child: StrPath, /) -> Traversable: ... @abstractmethod def read_bytes(self) -> bytes: ... @abstractmethod diff --git a/stdlib/importlib/resources/simple.pyi b/stdlib/importlib/resources/simple.pyi index c4c758111c2d..946987c7312f 100644 --- a/stdlib/importlib/resources/simple.pyi +++ b/stdlib/importlib/resources/simple.pyi @@ -1,5 +1,6 @@ import abc import sys +from _typeshed import StrPath from collections.abc import Iterator from io import TextIOWrapper from typing import IO, Any, BinaryIO, Literal, NoReturn, overload @@ -50,7 +51,7 @@ if sys.version_info >= (3, 11): def iterdir(self) -> Iterator[ResourceHandle | ResourceContainer]: ... def open(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override] if sys.version_info < (3, 12): - def joinpath(self, *descendants: str) -> Traversable: ... + def joinpath(self, *descendants: StrPath) -> Traversable: ... class TraversableReader(TraversableResources, SimpleReader, metaclass=abc.ABCMeta): def files(self) -> ResourceContainer: ...