8000 add new pathlib base classes for 3.13 by tungol · Pull Request #12937 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

add new pathlib base classes for 3.13 #12937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simplify PathBase.open
  • Loading branch information
tungol committed Nov 2, 2024
commit d8cec883586fa10e4eea70e95cb4795353d12660
66 changes: 3 additions & 63 deletions stdlib/pathlib/_abc.pyi
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
import types
from _typeshed import (
AnyOrLiteralStr,
BytesPath,
OpenBinaryMode,
OpenBinaryModeReading,
OpenBinaryModeUpdating,
OpenBinaryModeWriting,
OpenTextMode,
ReadableBuffer,
StrOrBytesPath,
StrPath,
)
from _typeshed import AnyOrLiteralStr, BytesPath, ReadableBuffer, StrOrBytesPath, StrPath
from collections.abc import Callable, Generator, Iterator, Sequence
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
from os import PathLike, stat_result
from typing import IO, Any, AnyStr, BinaryIO, ClassVar, Literal, overload
from typing import IO, Any, AnyStr, ClassVar, overload
from typing_extensions import LiteralString, Self

__all__ = ["UnsupportedOperation"]
Expand Down Expand Up @@ -95,61 +83,13 @@ class PathBase(PurePathBase):
def is_fifo(self) -> bool D44C : ...
def is_socket(self) -> bool: ...
def samefile(self, other_path: StrPath) -> bool: ...

# Adapted from builtins.open
# Text mode: always returns a TextIOWrapper
# The Traversable .open in stdlib/importlib/abc.pyi should be kept in sync with this.
@overload
def open(
self,
mode: OpenTextMode = "r",
mode: str = "r",
buffering: int = -1,
encoding: str | None = None,
errors: str | None = None,
newline: str | None = None,
) -> TextIOWrapper: ...
# Unbuffered binary mode: returns a FileIO
@overload
def open(
self, mode: OpenBinaryMode, buffering: Literal[0], encoding: None = None, errors: None = None, newline: None = None
) -> FileIO: ...
# Buffering is on: return BufferedRandom, BufferedReader, or BufferedWriter
@overload
def open(
self,
mode: OpenBinaryModeUpdating,
buffering: Literal[-1, 1] = -1,
encoding: None = None,
errors: None = None,
newline: None = None,
) -> BufferedRandom: ...
@overload
def open(
self,
mode: OpenBinaryModeWriting,
buffering: Literal[-1, 1] = -1,
encoding: None = None,
errors: None = None,
newline: None = None,
) -> BufferedWriter: ...
@overload
def open(
self,
mode: OpenBinaryModeReading,
buffering: Literal[-1, 1] = -1,
encoding: None = None,
errors: None = None,
newline: None = None,
) -> BufferedReader: ...
# Buffering cannot be determined: fall back to BinaryIO
@overload
def open(
self, mode: OpenBinaryMode, buffering: int = -1, encoding: None = None, errors: None = None, newline: None = None
) -> BinaryIO: ...
# Fallback if mode is not specified
@overload
def open(
self, mode: str, buffering: int = -1, encoding: str | None = None, errors: str | None = None, newline: str | None = None
) -> IO[Any]: ...
def read_bytes(self) -> bytes: ...
def read_text(self, encoding: str | None = None, errors: str | None = None, newline: str | None = None) -> str: ...
Expand Down
Loading
0