From b971439b43788f4896e2d37dd26938d1841cdef3 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Sun, 4 Jun 2023 15:45:20 +0100 Subject: [PATCH 1/2] `pathlib`: `is_mount()` is implemented on Windows on py312+ --- stdlib/pathlib.pyi | 3 +++ tests/stubtest_allowlists/win32-py310.txt | 1 + tests/stubtest_allowlists/win32-py311.txt | 1 + tests/stubtest_allowlists/win32-py37.txt | 1 + tests/stubtest_allowlists/win32-py38.txt | 1 + tests/stubtest_allowlists/win32-py39.txt | 1 + tests/stubtest_allowlists/win32.txt | 3 --- 7 files changed, 8 insertions(+), 3 deletions(-) diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index 7aec66b584e3..7c7251ad3dbe 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -159,6 +159,9 @@ class Path(PurePath): # so it's safer to pretend they don't exist def owner(self) -> str: ... def group(self) -> str: ... + + # This methods does "exist" on Windows, but always raises NotImplementedError on <3.12 + if sys.platform != "win32" or sys.version_info >= (3, 12): def is_mount(self) -> bool: ... if sys.version_info >= (3, 9): diff --git a/tests/stubtest_allowlists/win32-py310.txt b/tests/stubtest_allowlists/win32-py310.txt index 9999729feae6..e62c9f69670a 100644 --- a/tests/stubtest_allowlists/win32-py310.txt +++ b/tests/stubtest_allowlists/win32-py310.txt @@ -12,4 +12,5 @@ subprocess.STARTUPINFO.copy # pathlib methods that exist on Windows, but always raise NotImplementedError, # so are omitted from the stub +pathlib.Path.is_mount pathlib.WindowsPath.is_mount diff --git a/tests/stubtest_allowlists/win32-py311.txt b/tests/stubtest_allowlists/win32-py311.txt index 6a4bb0a3a451..f3eb72c32e2a 100644 --- a/tests/stubtest_allowlists/win32-py311.txt +++ b/tests/stubtest_allowlists/win32-py311.txt @@ -15,4 +15,5 @@ subprocess.STARTUPINFO.copy # pathlib methods that exist on Windows, but always raise NotImplementedError, # so are omitted from the stub +pathlib.Path.is_mount pathlib.WindowsPath.is_mount diff --git a/tests/stubtest_allowlists/win32-py37.txt b/tests/stubtest_allowlists/win32-py37.txt index e806f8fa45a3..05db77c1edb9 100644 --- a/tests/stubtest_allowlists/win32-py37.txt +++ b/tests/stubtest_allowlists/win32-py37.txt @@ -14,6 +14,7 @@ urllib.parse.parse_qsl # pathlib methods that exist on Windows, but always raise NotImplementedError, # so are omitted from the stub +pathlib.Path.is_mount pathlib.WindowsPath.group pathlib.WindowsPath.owner pathlib.WindowsPath.is_mount diff --git a/tests/stubtest_allowlists/win32-py38.txt b/tests/stubtest_allowlists/win32-py38.txt index 44d8c508eb3d..49369652991b 100644 --- a/tests/stubtest_allowlists/win32-py38.txt +++ b/tests/stubtest_allowlists/win32-py38.txt @@ -15,6 +15,7 @@ subprocess.STARTUPINFO.copy # pathlib methods that exist on Windows, but always raise NotImplementedError, # so are omitted from the stub +pathlib.Path.is_mount pathlib.WindowsPath.group pathlib.WindowsPath.owner pathlib.WindowsPath.is_mount diff --git a/tests/stubtest_allowlists/win32-py39.txt b/tests/stubtest_allowlists/win32-py39.txt index 5af02679e126..f61f8653c6ad 100644 --- a/tests/stubtest_allowlists/win32-py39.txt +++ b/tests/stubtest_allowlists/win32-py39.txt @@ -11,4 +11,5 @@ subprocess.STARTUPINFO.copy # pathlib methods that exist on Windows, but always raise NotImplementedError, # so are omitted from the stub +pathlib.Path.is_mount pathlib.WindowsPath.is_mount diff --git a/tests/stubtest_allowlists/win32.txt b/tests/stubtest_allowlists/win32.txt index 7e68abf51531..cc851bf28ba7 100644 --- a/tests/stubtest_allowlists/win32.txt +++ b/tests/stubtest_allowlists/win32.txt @@ -66,6 +66,3 @@ tty # pathlib functions that rely on modules that don't exist on Windows pathlib.Path.owner pathlib.Path.group -# pathlib methods that exist on Windows, but always raise NotImplementedError, -# so are omitted from the stub -pathlib.Path.is_mount From acc94042745fff4dee19ce74ce6804b396e077a1 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 4 Jun 2023 15:52:33 +0100 Subject: [PATCH 2/2] better comment --- stdlib/pathlib.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index 7c7251ad3dbe..e390e71785b1 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -160,7 +160,8 @@ class Path(PurePath): def owner(self) -> str: ... def group(self) -> str: ... - # This methods does "exist" on Windows, but always raises NotImplementedError on <3.12 + # This method does "exist" on Windows on <3.12, but always raises NotImplementedError + # On py312+, it works properly on Windows, as with all other platforms if sys.platform != "win32" or sys.version_info >= (3, 12): def is_mount(self) -> bool: ...