Skip to content

Commit f8dfacb

Browse files
authored
pathlib: more changes for py312 (#10261)
1 parent 758afb3 commit f8dfacb

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

stdlib/pathlib.pyi

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ class PurePath(PathLike[str]):
5555
if sys.version_info >= (3, 9):
5656
def is_relative_to(self, *other: StrPath) -> bool: ...
5757

58-
def match(self, path_pattern: str) -> bool: ...
58+
if sys.version_info >= (3, 12):
59+
def match(self, path_pattern: str, *, case_sensitive: bool | None = None) -> bool: ...
60+
else:
61+
def match(self, path_pattern: str) -> bool: ...
62+
5963
def relative_to(self, *other: StrPath) -> Self: ...
6064
def with_name(self, name: str) -> Self: ...
6165
if sys.version_info >= (3, 9):
@@ -70,6 +74,9 @@ class PurePath(PathLike[str]):
7074
if sys.version_info >= (3, 9) and sys.version_info < (3, 11):
7175
def __class_getitem__(cls, type: Any) -> GenericAlias: ...
7276

77+
if sys.version_info >= (3, 12):
78+
def with_segments(self, *args: StrPath) -> Self: ...
79+
7380
class PurePosixPath(PurePath): ...
7481
class PureWindowsPath(PurePath): ...
7582

@@ -86,15 +93,25 @@ class Path(PurePath):
8693
def stat(self) -> stat_result: ...
8794
def chmod(self, mode: int) -> None: ...
8895

89-
def exists(self) -> bool: ...
90-
def glob(self, pattern: str) -> Generator[Self, None, None]: ...
96+
if sys.version_info >= (3, 12):
97+
def exists(self, *, follow_symlinks: bool = True) -> bool: ...
98+
def glob(self, pattern: str, *, case_sensitive: bool | None = None) -> Generator[Self, None, None]: ...
99+
def rglob(self, pattern: str, *, case_sensitive: bool | None = None) -> Generator[Self, None, None]: ...
100+
else:
101+
def exists(self) -> bool: ...
102+
def glob(self, pattern: str) -> Generator[Self, None, None]: ...
103+
def rglob(self, pattern: str) -> Generator[Self, None, None]: ...
104+
91105
def is_dir(self) -> bool: ...
92106
def is_file(self) -> bool: ...
93107
def is_symlink(self) -> bool: ...
94108
def is_socket(self) -> bool: ...
95109
def is_fifo(self) -> bool: ...
96110
def is_block_device(self) -> bool: ...
97111
def is_char_device(self) -> bool: ...
112+
if sys.version_info >= (3, 12):
113+
def is_junction(self) -> bool: ...
114+
98115
def iterdir(self) -> Generator[Self, None, None]: ...
99116
def lchmod(self, mode: int) -> None: ...
100117
def lstat(self) -> stat_result: ...
@@ -175,7 +192,6 @@ class Path(PurePath):
175192
def replace(self, target: str | PurePath) -> None: ...
176193

177194
def resolve(self, strict: bool = False) -> Self: ...
178-
def rglob(self, pattern: str) -> Generator[Self, None, None]: ...
179195
def rmdir(self) -> None: ...
180196
def symlink_to(self, target: StrOrBytesPath, target_is_directory: bool = False) -> None: ...
181197
if sys.version_info >= (3, 10):

tests/stubtest_allowlists/py312.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,9 @@ os.path.__all__
115115
os.path.isjunction
116116
os.path.splitroot
117117
pathlib.Path.__init__
118-
pathlib.Path.exists
119-
pathlib.Path.glob
120-
pathlib.Path.is_junction
121-
pathlib.Path.rglob
122118
pathlib.PurePath.__init__
123119
pathlib.PurePath.is_relative_to
124-
pathlib.PurePath.match
125120
pathlib.PurePath.relative_to
126-
pathlib.PurePath.with_segments
127121
pdb.Pdb.set_convenience_variable
128122
pkgutil.ImpImporter
129123
pkgutil.ImpLoader

0 commit comments

Comments
 (0)