diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index f2599c720..348784b94 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -54,7 +54,7 @@ class PurePath(PathLike[str]): def parents(self: Self) -> Sequence[Self]: ... @property def parent(self: Self) -> Self: ... - if sys.version_info >= (3, 9): + if sys.version_info >= (3, 9) and sys.version_info < (3, 11): def __class_getitem__(cls, type: Any) -> GenericAlias: ... class PurePosixPath(PurePath): ... @@ -77,12 +77,8 @@ class Path(PurePath): def exists(self) -> bool: ... def glob(self: Self, pattern: str) -> Generator[Self, None, None]: ... - def group(self) -> str: ... def is_dir(self) -> bool: ... def is_file(self) -> bool: ... - if sys.version_info >= (3, 7): - def is_mount(self) -> bool: ... - def is_symlink(self) -> bool: ... def is_socket(self) -> bool: ... def is_fifo(self) -> bool: ... @@ -147,7 +143,14 @@ class Path(PurePath): def open( self, mode: str, buffering: int = ..., encoding: str | None = ..., errors: str | None = ..., newline: str | None = ... ) -> IO[Any]: ... - def owner(self) -> str: ... + if sys.platform != "win32": + # These methods do "exist" on Windows, but they always raise NotImplementedError, + # so it's safer to pretend they don't exist + def owner(self) -> str: ... + def group(self) -> str: ... + if sys.version_info >= (3, 7): + def is_mount(self) -> bool: ... + if sys.version_info >= (3, 9): def readlink(self: Self) -> Self: ... if sys.version_info >= (3, 8): diff --git a/tests/stubtest_allowlists/win32-py310.txt b/tests/stubtest_allowlists/win32-py310.txt index c57296600..2fcacc00a 100644 --- a/tests/stubtest_allowlists/win32-py310.txt +++ b/tests/stubtest_allowlists/win32-py310.txt @@ -6,6 +6,11 @@ sqlite3.Connection.load_extension sqlite3.dbapi2.Connection.enable_load_extension sqlite3.dbapi2.Connection.load_extension +# pathlib methods that exist on Windows, but always raise NotImplementedError, +# so are omitted from the stub +pathlib.WindowsPath.is_mount +pathlib.Path.is_mount + # Exists at runtime, but missing from stubs _winapi.CreateFileMapping _winapi.MapViewOfFile diff --git a/tests/stubtest_allowlists/win32-py36.txt b/tests/stubtest_allowlists/win32-py36.txt index d4d7869aa..768616bdb 100644 --- a/tests/stubtest_allowlists/win32-py36.txt +++ b/tests/stubtest_allowlists/win32-py36.txt @@ -7,6 +7,11 @@ cgi.parse urllib.parse.parse_qs urllib.parse.parse_qsl +# pathlib methods that exist on Windows, but always raise NotImplementedError, +# so are omitted from the stub +pathlib.WindowsPath.group +pathlib.WindowsPath.owner + hashlib.scrypt os.startfile diff --git a/tests/stubtest_allowlists/win32-py37.txt b/tests/stubtest_allowlists/win32-py37.txt index 1f1456940..0ab3ff7e0 100644 --- a/tests/stubtest_allowlists/win32-py37.txt +++ b/tests/stubtest_allowlists/win32-py37.txt @@ -8,6 +8,13 @@ cgi.parse_multipart urllib.parse.parse_qs urllib.parse.parse_qsl +# pathlib methods that exist on Windows, but always raise NotImplementedError, +# so are omitted from the stub +pathlib.WindowsPath.group +pathlib.WindowsPath.owner +pathlib.Path.is_mount +pathlib.WindowsPath.is_mount + os.startfile # Exists at runtime, but missing from stubs diff --git a/tests/stubtest_allowlists/win32-py38.txt b/tests/stubtest_allowlists/win32-py38.txt index ddb834085..bae39db29 100644 --- a/tests/stubtest_allowlists/win32-py38.txt +++ b/tests/stubtest_allowlists/win32-py38.txt @@ -1,3 +1,10 @@ +# pathlib methods that exist on Windows, but always raise NotImplementedError, +# so are omitted from the stub +pathlib.WindowsPath.group +pathlib.WindowsPath.owner +pathlib.Path.is_mount +pathlib.WindowsPath.is_mount + # Exists at runtime, but missing from stubs _winapi.CreateFileMapping _winapi.MapViewOfFile diff --git a/tests/stubtest_allowlists/win32-py39.txt b/tests/stubtest_allowlists/win32-py39.txt index ddb834085..f8e07f9fd 100644 --- a/tests/stubtest_allowlists/win32-py39.txt +++ b/tests/stubtest_allowlists/win32-py39.txt @@ -1,3 +1,8 @@ +# pathlib methods that exist on Windows, but always raise NotImplementedError, +# so are omitted from the stub +pathlib.Path.is_mount +pathlib.WindowsPath.is_mount + # Exists at runtime, but missing from stubs _winapi.CreateFileMapping _winapi.MapViewOfFile diff --git a/tests/stubtest_allowlists/win32.txt b/tests/stubtest_allowlists/win32.txt index 1222e707a..f95a753f0 100644 --- a/tests/stubtest_allowlists/win32.txt +++ b/tests/stubtest_allowlists/win32.txt @@ -56,6 +56,10 @@ curses.textpad pty tty +# pathlib functions that rely on modules that don't exist on Windows +pathlib.Path.owner +pathlib.Path.group + # Exists at runtime, but missing from stubs _msi.MSIError asyncio.windows_utils.Popen