diff --git a/stdlib/dbm/gnu.pyi b/stdlib/dbm/gnu.pyi index ef4706b97f74..b0e657d6ae4b 100644 --- a/stdlib/dbm/gnu.pyi +++ b/stdlib/dbm/gnu.pyi @@ -1,39 +1,39 @@ +import sys from _typeshed import Self from types import TracebackType from typing import TypeVar, Union, overload -_T = TypeVar("_T") -_KeyType = Union[str, bytes] -_ValueType = Union[str, bytes] +if sys.platform != "win32": + _T = TypeVar("_T") + _KeyType = Union[str, bytes] + _ValueType = Union[str, bytes] -open_flags: str + open_flags: str -class error(OSError): ... - -# Actual typename gdbm, not exposed by the implementation -class _gdbm: - def firstkey(self) -> bytes | None: ... - def nextkey(self, key: _KeyType) -> bytes | None: ... - def reorganize(self) -> None: ... - def sync(self) -> None: ... - def close(self) -> None: ... - def __getitem__(self, item: _KeyType) -> bytes: ... - def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ... - def __delitem__(self, key: _KeyType) -> None: ... - def __contains__(self, key: _KeyType) -> bool: ... - def __len__(self) -> int: ... - def __enter__(self: Self) -> Self: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> None: ... - @overload - def get(self, k: _KeyType) -> bytes | None: ... - @overload - def get(self, k: _KeyType, default: bytes | _T) -> bytes | _T: ... - def keys(self) -> list[bytes]: ... - def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ... - # Don't exist at runtime - __new__: None # type: ignore[assignment] - __init__: None # type: ignore[assignment] - -def open(__filename: str, __flags: str = ..., __mode: int = ...) -> _gdbm: ... + class error(OSError): ... + # Actual typename gdbm, not exposed by the implementation + class _gdbm: + def firstkey(self) -> bytes | None: ... + def nextkey(self, key: _KeyType) -> bytes | None: ... + def reorganize(self) -> None: ... + def sync(self) -> None: ... + def close(self) -> None: ... + def __getitem__(self, item: _KeyType) -> bytes: ... + def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ... + def __delitem__(self, key: _KeyType) -> None: ... + def __contains__(self, key: _KeyType) -> bool: ... + def __len__(self) -> int: ... + def __enter__(self: Self) -> Self: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> None: ... + @overload + def get(self, k: _KeyType) -> bytes | None: ... + @overload + def get(self, k: _KeyType, default: bytes | _T) -> bytes | _T: ... + def keys(self) -> list[bytes]: ... + def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ... + # Don't exist at runtime + __new__: None # type: ignore[assignment] + __init__: None # type: ignore[assignment] + def open(__filename: str, __flags: str = ..., __mode: int = ...) -> _gdbm: ... diff --git a/stdlib/dbm/ndbm.pyi b/stdlib/dbm/ndbm.pyi index c49ad82c53d4..336720c79f37 100644 --- a/stdlib/dbm/ndbm.pyi +++ b/stdlib/dbm/ndbm.pyi @@ -1,35 +1,35 @@ +import sys from _typeshed import Self from types import TracebackType from typing import TypeVar, Union, overload -_T = TypeVar("_T") -_KeyType = Union[str, bytes] -_ValueType = Union[str, bytes] +if sys.platform != "win32": + _T = TypeVar("_T") + _KeyType = Union[str, bytes] + _ValueType = Union[str, bytes] -class error(OSError): ... + class error(OSError): ... + library: str -library: str - -# Actual typename dbm, not exposed by the implementation -class _dbm: - def close(self) -> None: ... - def __getitem__(self, item: _KeyType) -> bytes: ... - def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ... - def __delitem__(self, key: _KeyType) -> None: ... - def __len__(self) -> int: ... - def __del__(self) -> None: ... - def __enter__(self: Self) -> Self: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> None: ... - @overload - def get(self, k: _KeyType) -> bytes | None: ... - @overload - def get(self, k: _KeyType, default: bytes | _T) -> bytes | _T: ... - def keys(self) -> list[bytes]: ... - def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ... - # Don't exist at runtime - __new__: None # type: ignore[assignment] - __init__: None # type: ignore[assignment] - -def open(__filename: str, __flags: str = ..., __mode: int = ...) -> _dbm: ... + # Actual typename dbm, not exposed by the implementation + class _dbm: + def close(self) -> None: ... + def __getitem__(self, item: _KeyType) -> bytes: ... + def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ... + def __delitem__(self, key: _KeyType) -> None: ... + def __len__(self) -> int: ... + def __del__(self) -> None: ... + def __enter__(self: Self) -> Self: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> None: ... + @overload + def get(self, k: _KeyType) -> bytes | None: ... + @overload + def get(self, k: _KeyType, default: bytes | _T) -> bytes | _T: ... + def keys(self) -> list[bytes]: ... + def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ... + # Don't exist at runtime + __new__: None # type: ignore[assignment] + __init__: None # type: ignore[assignment] + def open(__filename: str, __flags: str = ..., __mode: int = ...) -> _dbm: ... diff --git a/stdlib/shutil.pyi b/stdlib/shutil.pyi index 752cf2cb5a8d..55c964fbdcf9 100644 --- a/stdlib/shutil.pyi +++ b/stdlib/shutil.pyi @@ -100,14 +100,18 @@ class _ntuple_diskusage(NamedTuple): free: int def disk_usage(path: int | StrOrBytesPath) -> _ntuple_diskusage: ... -@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.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: ... if sys.version_info >= (3, 8): @overload diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index e97a66f5e8c5..461ea41406c8 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -12,8 +12,6 @@ from typing_extensions import Literal import _socket from _socket import ( _FD, - CMSG_LEN as CMSG_LEN, - CMSG_SPACE as CMSG_SPACE, EAI_ADDRFAMILY as EAI_ADDRFAMILY, EAI_AGAIN as EAI_AGAIN, EAI_BADFLAGS as EAI_BADFLAGS, @@ -213,7 +211,7 @@ from _socket import ( if sys.version_info >= (3, 7): from _socket import close as close if sys.platform != "win32": - from _socket import sethostname as sethostname + from _socket import CMSG_LEN as CMSG_LEN, CMSG_SPACE as CMSG_SPACE, sethostname as sethostname if sys.platform != "win32" or sys.version_info >= (3, 8): from _socket import if_indextoname as if_indextoname, if_nameindex as if_nameindex, if_nametoindex as if_nametoindex if sys.platform == "linux": diff --git a/tests/stubtest_allowlists/win32.txt b/tests/stubtest_allowlists/win32.txt index 6f25a3ad7bce..db20aaf3822b 100644 --- a/tests/stubtest_allowlists/win32.txt +++ b/tests/stubtest_allowlists/win32.txt @@ -78,3 +78,6 @@ ssl.SSLSocket.recvmsg ssl.SSLSocket.recvmsg_into ssl.SSLSocket.sendmsg winreg.HKEYType.handle + +# exist but do not work on Windows +shutil.chown