mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-06-24 17:54:01 +08:00
[importlib] Traversable joinpath and __truediv__ allows StrPath (#15108)
This commit is contained in:
@@ -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: ...
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
Reference in New Issue
Block a user