From 2fb9c35ff93db0e8e7297cbb5860a7bb6aa5dfa6 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 6 Mar 2022 16:27:24 -0800 Subject: [PATCH] Put shutil.chown back on Windows (#7446) See #7384 and https://github.com/python/typeshed/pull/7443#issuecomment-1060071944 (thanks @AlexWaygood for diagnosing). --- stdlib/shutil.pyi | 22 +++++++++++----------- tests/stubtest_allowlists/win32.txt | 3 --- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/stdlib/shutil.pyi b/stdlib/shutil.pyi index 55c964fbd..030f16cd9 100644 --- a/stdlib/shutil.pyi +++ b/stdlib/shutil.pyi @@ -101,17 +101,17 @@ class _ntuple_diskusage(NamedTuple): def disk_usage(path: int | StrOrBytesPath) -> _ntuple_diskusage: ... -if sys.platform != "win32": - # while chown can be imported on Windows it doesn't actually work - # see https://bugs.python.org/issue33140 - @overload - def chown(path: StrOrBytesPath, user: str | int, group: None = ...) -> None: ... - @overload - def chown(path: StrOrBytesPath, user: None = ..., *, group: str | int) -> None: ... - @overload - def chown(path: StrOrBytesPath, user: None, group: str | int) -> None: ... - @overload - def chown(path: StrOrBytesPath, user: str | int, group: str | int) -> None: ... +# While chown can be imported on Windows, it doesn't actually work; +# see https://bugs.python.org/issue33140. We keep it here because it's +# in __all__. +@overload +def chown(path: StrOrBytesPath, user: str | int, group: None = ...) -> None: ... +@overload +def chown(path: StrOrBytesPath, user: None = ..., *, group: str | int) -> None: ... +@overload +def chown(path: StrOrBytesPath, user: None, group: str | int) -> None: ... +@overload +def chown(path: StrOrBytesPath, user: str | int, group: str | int) -> None: ... if sys.version_info >= (3, 8): @overload diff --git a/tests/stubtest_allowlists/win32.txt b/tests/stubtest_allowlists/win32.txt index f7d68a3a0..ec7c2a84c 100644 --- a/tests/stubtest_allowlists/win32.txt +++ b/tests/stubtest_allowlists/win32.txt @@ -75,6 +75,3 @@ ssl.SSLSocket.recvmsg ssl.SSLSocket.recvmsg_into ssl.SSLSocket.sendmsg winreg.HKEYType.handle - -# exist but do not work on Windows -shutil.chown