Skip to content

Commit 90d89f8

Browse files
authored
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.
1 parent 5f1fd23 commit 90d89f8

File tree

2 files changed

+32
-60
lines changed

2 files changed

+32
-60
lines changed

stdlib/zipfile/__init__.pyi

-8
Original file line numberDiff line numberDiff line change
@@ -362,14 +362,6 @@ else:
362362
def joinpath(self, *other: StrPath) -> Path: ...
363363
else:
364364
def joinpath(self, add: StrPath) -> Path: ... # undocumented
365-
if sys.version_info >= (3, 12):
366-
def glob(self, pattern: str) -> Iterator[Self]: ...
367-
def rglob(self, pattern: str) -> Iterator[Self]: ...
368-
def is_symlink(self) -> Literal[False]: ...
369-
def relative_to(self, other: Path, *extra: StrPath) -> str: ...
370-
def match(self, path_pattern: str) -> bool: ...
371-
def __eq__(self, other: object) -> bool: ...
372-
def __hash__(self) -> int: ...
373365

374366
def __truediv__(self, add: StrPath) -> Path: ...
375367

stdlib/zipfile/_path/__init__.pyi

+32-52
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ from collections.abc import Iterator, Sequence
44
from io import TextIOWrapper
55
from os import PathLike
66
from typing import IO, Literal, TypeVar, overload
7-
from typing_extensions import Self, TypeAlias
7+
from typing_extensions import Self
88
from zipfile import ZipFile
99

10-
_ReadWriteBinaryMode: TypeAlias = Literal["r", "w", "rb", "wb"]
11-
1210
_ZF = TypeVar("_ZF", bound=ZipFile)
1311

1412
if sys.version_info >= (3, 12):
@@ -39,42 +37,29 @@ if sys.version_info >= (3, 12):
3937
def name(self) -> str: ...
4038
@property
4139
def parent(self) -> PathLike[str]: ... # undocumented
42-
if sys.version_info >= (3, 10):
43-
@property
44-
def filename(self) -> PathLike[str]: ... # undocumented
45-
if sys.version_info >= (3, 11):
46-
@property
47-
def suffix(self) -> str: ...
48-
@property
49-
def suffixes(self) -> list[str]: ...
50-
@property
51-
def stem(self) -> str: ...
52-
53-
if sys.version_info >= (3, 9):
54-
@overload
55-
def open(
56-
self,
57-
mode: Literal["r", "w"] = "r",
58-
encoding: str | None = None,
59-
errors: str | None = None,
60-
newline: str | None = None,
61-
line_buffering: bool = ...,
62-
write_through: bool = ...,
63-
*,
64-
pwd: bytes | None = None,
65-
) -> TextIOWrapper: ...
66-
@overload
67-
def open(self, mode: Literal["rb", "wb"], *, pwd: bytes | None = None) -> IO[bytes]: ...
68-
else:
69-
def open(
70-
self, mode: _ReadWriteBinaryMode = "r", pwd: bytes | None = None, *, force_zip64: bool = False
71-
) -> IO[bytes]: ...
72-
73-
if sys.version_info >= (3, 10):
74-
def iterdir(self) -> Iterator[Self]: ...
75-
else:
76-
def iterdir(self) -> Iterator[Path]: ...
77-
40+
@property
41+
def filename(self) -> PathLike[str]: ... # undocumented
42+
@property
43+
def suffix(self) -> str: ...
44+
@property
45+
def suffixes(self) -> list[str]: ...
46+
@property
47+
def stem(self) -> str: ...
48+
@overload
49+
def open(
50+
self,
51+
mode: Literal["r", "w"] = "r",
52+
encoding: str | None = None,
53+
errors: str | None = None,
54+
newline: str | None = None,
55+
line_buffering: bool = ...,
56+
write_through: bool = ...,
57+
*,
58+
pwd: bytes | None = None,
59+
) -> TextIOWrapper: ...
60+
@overload
61+
def open(self, mode: Literal["rb", "wb"], *, pwd: bytes | None = None) -> IO[bytes]: ...
62+
def iterdir(self) -> Iterator[Self]: ...
7863
def is_dir(self) -> bool: ...
7964
def is_file(self) -> bool: ...
8065
def exists(self) -> bool: ...
@@ -87,17 +72,12 @@ if sys.version_info >= (3, 12):
8772
write_through: bool = ...,
8873
) -> str: ...
8974
def read_bytes(self) -> bytes: ...
90-
if sys.version_info >= (3, 10):
91-
def joinpath(self, *other: StrPath) -> Path: ...
92-
else:
93-
def joinpath(self, add: StrPath) -> Path: ... # undocumented
94-
if sys.version_info >= (3, 12):
95-
def glob(self, pattern: str) -> Iterator[Self]: ...
96-
def rglob(self, pattern: str) -> Iterator[Self]: ...
97-
def is_symlink(self) -> Literal[False]: ...
98-
def relative_to(self, other: Path, *extra: StrPath) -> str: ...
99-
def match(self, path_pattern: str) -> bool: ...
100-
def __eq__(self, other: object) -> bool: ...
101-
def __hash__(self) -> int: ...
102-
75+
def joinpath(self, *other: StrPath) -> Path: ...
76+
def glob(self, pattern: str) -> Iterator[Self]: ...
77+
def rglob(self, pattern: str) -> Iterator[Self]: ...
78+
def is_symlink(self) -> Literal[False]: ...
79+
def relative_to(self, other: Path, *extra: StrPath) -> str: ...
80+
def match(self, path_pattern: str) -> bool: ...
81+
def __eq__(self, other: object) -> bool: ...
82+
def __hash__(self) -> int: ...
10383
def __truediv__(self, add: StrPath) -> Path: ...

0 commit comments

Comments
 (0)