Update pathlib for 3.14 (#14006)

This commit is contained in:
Max Muoto
2025-05-11 21:44:37 +02:00
committed by GitHub
parent 251570c4f6
commit 268a2e71bd
5 changed files with 59 additions and 33 deletions
@@ -147,16 +147,6 @@ multiprocessing.process.BaseProcess.interrupt
multiprocessing.synchronize.SemLock.locked
os.__all__
os.readinto
pathlib.Path.copy_into
pathlib.Path.copytree
pathlib.Path.delete
pathlib.Path.info
pathlib.Path.move
pathlib.Path.move_into
pathlib.Path.rmtree
pathlib.PurePath.is_relative_to
pathlib.PurePath.relative_to
pathlib.types
pdb.__all__
pdb.Pdb.__init__
pdb.Pdb.checkline
+19 -3
View File
@@ -4,6 +4,10 @@ import sys
from pathlib import Path, PureWindowsPath
from typing_extensions import assert_type
class MyCustomPath(Path): ...
if Path("asdf") == Path("asdf"):
...
@@ -23,8 +27,20 @@ if PureWindowsPath("asdf") == Path("asdf"): # type: ignore
if sys.version_info >= (3, 13):
class MyCustomPath(Path): ...
pth = MyCustomPath.from_uri("file:///tmp/abc.txt")
assert_type(pth, MyCustomPath)
if sys.version_info >= (3, 14):
pth = MyCustomPath("asdf")
# With text path, type should be preserved.
assert_type(pth.move_into("asdf"), MyCustomPath)
assert_type(pth.move("asdf"), MyCustomPath)
assert_type(pth.copy("asdf"), MyCustomPath)
assert_type(pth.copy_into("asdf"), MyCustomPath)
# With an actual path type, that type should be preserved.
assert_type(pth.move_into(Path("asdf")), Path)
assert_type(pth.move(Path("asdf")), Path)
assert_type(pth.copy(Path("asdf")), Path)
assert_type(pth.copy_into(Path("asdf")), Path)