Skip to content

Commit d9f078f

Browse files
authored
[importlib] Traversable joinpath and __truediv__ allows StrPath (#15108)
1 parent de81abb commit d9f078f

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

stdlib/importlib/readers.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ if sys.version_info >= (3, 10):
5252
def is_file(self) -> Literal[False]: ...
5353

5454
if sys.version_info >= (3, 12):
55-
def joinpath(self, *descendants: str) -> abc.Traversable: ...
55+
def joinpath(self, *descendants: StrPath) -> abc.Traversable: ...
5656
elif sys.version_info >= (3, 11):
57-
def joinpath(self, child: str) -> abc.Traversable: ... # type: ignore[override]
57+
def joinpath(self, child: StrPath) -> abc.Traversable: ... # type: ignore[override]
5858
else:
5959
def joinpath(self, child: str) -> abc.Traversable: ...
6060

stdlib/importlib/resources/abc.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
from _typeshed import StrPath
23
from abc import ABCMeta, abstractmethod
34
from collections.abc import Iterator
45
from io import BufferedReader
@@ -24,7 +25,7 @@ if sys.version_info >= (3, 11):
2425
@abstractmethod
2526
def iterdir(self) -> Iterator[Traversable]: ...
2627
@abstractmethod
27-
def joinpath(self, *descendants: str) -> Traversable: ...
28+
def joinpath(self, *descendants: StrPath) -> Traversable: ...
2829

2930
# The documentation and runtime protocol allows *args, **kwargs arguments,
3031
# but this would mean that all implementers would have to support them,
@@ -38,7 +39,7 @@ if sys.version_info >= (3, 11):
3839
@property
3940
@abstractmethod
4041
def name(self) -> str: ...
41-
def __truediv__(self, child: str, /) -> Traversable: ...
42+
def __truediv__(self, child: StrPath, /) -> Traversable: ...
4243
@abstractmethod
4344
def read_bytes(self) -> bytes: ...
4445
@abstractmethod

stdlib/importlib/resources/simple.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import abc
22
import sys
3+
from _typeshed import StrPath
34
from collections.abc import Iterator
45
from io import TextIOWrapper
56
from typing import IO, Any, BinaryIO, Literal, NoReturn, overload
@@ -50,7 +51,7 @@ if sys.version_info >= (3, 11):
5051
def iterdir(self) -> Iterator[ResourceHandle | ResourceContainer]: ...
5152
def open(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override]
5253
if sys.version_info < (3, 12):
53-
def joinpath(self, *descendants: str) -> Traversable: ...
54+
def joinpath(self, *descendants: StrPath) -> Traversable: ...
5455

5556
class TraversableReader(TraversableResources, SimpleReader, metaclass=abc.ABCMeta):
5657
def files(self) -> ResourceContainer: ...

0 commit comments

Comments
 (0)