Remove redundant version_info checks (#13588)

`zipfile._path` was split into a separate module in Python 3.12.
Originally, we just copied the definition for `CompleteDirs` and `Path`
from `zipfile.pyi` to `zipfile/_path/__init__.pyi` and left the now
defunct version_info branches. This removes the unnecessary branches
from the respective stub files.
This commit is contained in:
Sebastian Rittau
2025-03-06 17:02:48 +01:00
committed by GitHub
parent 5f1fd23bd2
commit 90d89f8983
2 changed files with 32 additions and 60 deletions
-8
View File
@@ -362,14 +362,6 @@ else:
def joinpath(self, *other: StrPath) -> Path: ...
else:
def joinpath(self, add: StrPath) -> Path: ... # undocumented
if sys.version_info >= (3, 12):
def glob(self, pattern: str) -> Iterator[Self]: ...
def rglob(self, pattern: str) -> Iterator[Self]: ...
def is_symlink(self) -> Literal[False]: ...
def relative_to(self, other: Path, *extra: StrPath) -> str: ...
def match(self, path_pattern: str) -> bool: ...
def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...
def __truediv__(self, add: StrPath) -> Path: ...
+32 -52
View File
@@ -4,11 +4,9 @@ from collections.abc import Iterator, Sequence
from io import TextIOWrapper
from os import PathLike
from typing import IO, Literal, TypeVar, overload
from typing_extensions import Self, TypeAlias
from typing_extensions import Self
from zipfile import ZipFile
_ReadWriteBinaryMode: TypeAlias = Literal["r", "w", "rb", "wb"]
_ZF = TypeVar("_ZF", bound=ZipFile)
if sys.version_info >= (3, 12):
@@ -39,42 +37,29 @@ if sys.version_info >= (3, 12):
def name(self) -> str: ...
@property
def parent(self) -> PathLike[str]: ... # undocumented
if sys.version_info >= (3, 10):
@property
def filename(self) -> PathLike[str]: ... # undocumented
if sys.version_info >= (3, 11):
@property
def suffix(self) -> str: ...
@property
def suffixes(self) -> list[str]: ...
@property
def stem(self) -> str: ...
if sys.version_info >= (3, 9):
@overload
def open(
self,
mode: Literal["r", "w"] = "r",
encoding: str | None = None,
errors: str | None = None,
newline: str | None = None,
line_buffering: bool = ...,
write_through: bool = ...,
*,
pwd: bytes | None = None,
) -> TextIOWrapper: ...
@overload
def open(self, mode: Literal["rb", "wb"], *, pwd: bytes | None = None) -> IO[bytes]: ...
else:
def open(
self, mode: _ReadWriteBinaryMode = "r", pwd: bytes | None = None, *, force_zip64: bool = False
) -> IO[bytes]: ...
if sys.version_info >= (3, 10):
def iterdir(self) -> Iterator[Self]: ...
else:
def iterdir(self) -> Iterator[Path]: ...
@property
def filename(self) -> PathLike[str]: ... # undocumented
@property
def suffix(self) -> str: ...
@property
def suffixes(self) -> list[str]: ...
@property
def stem(self) -> str: ...
@overload
def open(
self,
mode: Literal["r", "w"] = "r",
encoding: str | None = None,
errors: str | None = None,
newline: str | None = None,
line_buffering: bool = ...,
write_through: bool = ...,
*,
pwd: bytes | None = None,
) -> TextIOWrapper: ...
@overload
def open(self, mode: Literal["rb", "wb"], *, pwd: bytes | None = None) -> IO[bytes]: ...
def iterdir(self) -> Iterator[Self]: ...
def is_dir(self) -> bool: ...
def is_file(self) -> bool: ...
def exists(self) -> bool: ...
@@ -87,17 +72,12 @@ if sys.version_info >= (3, 12):
write_through: bool = ...,
) -> str: ...
def read_bytes(self) -> bytes: ...
if sys.version_info >= (3, 10):
def joinpath(self, *other: StrPath) -> Path: ...
else:
def joinpath(self, add: StrPath) -> Path: ... # undocumented
if sys.version_info >= (3, 12):
def glob(self, pattern: str) -> Iterator[Self]: ...
def rglob(self, pattern: str) -> Iterator[Self]: ...
def is_symlink(self) -> Literal[False]: ...
def relative_to(self, other: Path, *extra: StrPath) -> str: ...
def match(self, path_pattern: str) -> bool: ...
def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...
def joinpath(self, *other: StrPath) -> Path: ...
def glob(self, pattern: str) -> Iterator[Self]: ...
def rglob(self, pattern: str) -> Iterator[Self]: ...
def is_symlink(self) -> Literal[False]: ...
def relative_to(self, other: Path, *extra: StrPath) -> str: ...
def match(self, path_pattern: str) -> bool: ...
def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...
def __truediv__(self, add: StrPath) -> Path: ...