Skip to content

Commit d3a87eb

Browse files
authored
Improve types and bytes usage of pathlib (#9016)
1 parent 093c58b commit d3a87eb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

stdlib/pathlib.pyi

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ from _typeshed import (
55
OpenBinaryModeUpdating,
66
OpenBinaryModeWriting,
77
OpenTextMode,
8+
ReadableBuffer,
89
Self,
10+
StrOrBytesPath,
911
StrPath,
1012
)
1113
from collections.abc import Callable, Generator, Iterator, Sequence
@@ -188,16 +190,16 @@ class Path(PurePath):
188190
def expanduser(self: Self) -> Self: ...
189191
def read_bytes(self) -> bytes: ...
190192
def read_text(self, encoding: str | None = ..., errors: str | None = ...) -> str: ...
191-
def samefile(self, other_path: str | bytes | int | Path) -> bool: ...
192-
def write_bytes(self, data: bytes) -> int: ...
193+
def samefile(self, other_path: StrPath) -> bool: ...
194+
def write_bytes(self, data: ReadableBuffer) -> int: ...
193195
if sys.version_info >= (3, 10):
194196
def write_text(
195197
self, data: str, encoding: str | None = ..., errors: str | None = ..., newline: str | None = ...
196198
) -> int: ...
197199
else:
198200
def write_text(self, data: str, encoding: str | None = ..., errors: str | None = ...) -> int: ...
199-
if sys.version_info >= (3, 8):
200-
def link_to(self, target: StrPath | bytes) -> None: ...
201+
if sys.version_info >= (3, 8) and sys.version_info < (3, 12):
202+
def link_to(self, target: StrOrBytesPath) -> None: ...
201203
if sys.version_info >= (3, 12):
202204
def walk(
203205
self: Self, top_down: bool = ..., on_error: Callable[[OSError], object] | None = ..., follow_symlinks: bool = ...

0 commit comments

Comments
 (0)