Skip to content

Commit fd29812

Browse files
committed
[stdlib] Align Traversable joinpath and __truediv__ with CPython
The CPython implementation accepts `str | os.PathLike[str]`, typeshed only accepts `str`. CPython 3.13 implementations: https://github.com/python/cpython/blob/59f247e43bc93c607a5793c220bcaafb712cf542/Lib/importlib/resources/abc.py#L104 https://github.com/python/cpython/blob/59f247e43bc93c607a5793c220bcaafb712cf542/Lib/importlib/resources/abc.py#L129
1 parent 5d41fd6 commit fd29812

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

stdlib/importlib/resources/abc.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ from collections.abc import Iterator
44
from io import BufferedReader
55
from typing import IO, Any, Literal, Protocol, overload, runtime_checkable
66

7+
from _typeshed import StrPath
8+
79
if sys.version_info >= (3, 11):
810
class ResourceReader(metaclass=ABCMeta):
911
@abstractmethod
@@ -24,7 +26,7 @@ if sys.version_info >= (3, 11):
2426
@abstractmethod
2527
def iterdir(self) -> Iterator[Traversable]: ...
2628
@abstractmethod
27-
def joinpath(self, *descendants: str) -> Traversable: ...
29+
def joinpath(self, *descendants: StrPath) -> Traversable: ...
2830

2931
# The documentation and runtime protocol allows *args, **kwargs arguments,
3032
# but this would mean that all implementers would have to support them,
@@ -38,7 +40,7 @@ if sys.version_info >= (3, 11):
3840
@property
3941
@abstractmethod
4042
def name(self) -> str: ...
41-
def __truediv__(self, child: str, /) -> Traversable: ...
43+
def __truediv__(self, child: StrPath, /) -> Traversable: ...
4244
@abstractmethod
4345
def read_bytes(self) -> bytes: ...
4446
@abstractmethod

0 commit comments

Comments
 (0)