diff --git a/stdlib/grp.pyi b/stdlib/grp.pyi index 5b5855583..8447f2173 100644 --- a/stdlib/grp.pyi +++ b/stdlib/grp.pyi @@ -7,5 +7,5 @@ class struct_group(NamedTuple): gr_mem: List[str] def getgrall() -> List[struct_group]: ... -def getgrgid(gid: int) -> struct_group: ... +def getgrgid(id: int) -> struct_group: ... def getgrnam(name: str) -> struct_group: ... diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index 1d315fc12..e3f5d9b35 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -768,7 +768,13 @@ def getnameinfo(sockaddr: Union[Tuple[str, int], Tuple[str, int, int, int]], fla def getprotobyname(protocolname: str) -> int: ... def getservbyname(servicename: str, protocolname: str = ...) -> int: ... def getservbyport(port: int, protocolname: str = ...) -> str: ... -def socketpair(family: int = ..., type: int = ..., proto: int = ...) -> Tuple[socket, socket]: ... + +if sys.platform == "win32": + def socketpair(family: int = ..., type: int = ..., proto: int = ...) -> Tuple[socket, socket]: ... + +else: + def socketpair(family: Optional[int] = ..., type: int = ..., proto: int = ...) -> Tuple[socket, socket]: ... + def ntohl(x: int) -> int: ... # param & ret val are 32-bit ints def ntohs(x: int) -> int: ... # param & ret val are 16-bit ints def htonl(x: int) -> int: ... # param & ret val are 32-bit ints diff --git a/stdlib/spwd.pyi b/stdlib/spwd.pyi index 1fb972f6d..8a6656194 100644 --- a/stdlib/spwd.pyi +++ b/stdlib/spwd.pyi @@ -12,4 +12,4 @@ class struct_spwd(NamedTuple): sp_flag: int def getspall() -> List[struct_spwd]: ... -def getspnam(name: str) -> struct_spwd: ... +def getspnam(__arg: str) -> struct_spwd: ... diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index ba7fe8cc3..3f09496a6 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -1,5 +1,6 @@ import os import ssl +import sys from email.message import Message from http.client import HTTPMessage, HTTPResponse, _HTTPConnectionProtocol from http.cookiejar import CookieJar @@ -38,12 +39,22 @@ def urlopen( ) -> _UrlopenRet: ... def install_opener(opener: OpenerDirector) -> None: ... def build_opener(*handlers: Union[BaseHandler, Callable[[], BaseHandler]]) -> OpenerDirector: ... -def url2pathname(pathname: str) -> str: ... -def pathname2url(pathname: str) -> str: ... + +if sys.platform == "win32": + from nturl2path import pathname2url as pathname2url, url2pathname as url2pathname +else: + def url2pathname(pathname: str) -> str: ... + def pathname2url(pathname: str) -> str: ... + def getproxies() -> Dict[str, str]: ... def parse_http_list(s: str) -> List[str]: ... def parse_keqv_list(l: List[str]) -> Dict[str, str]: ... -def proxy_bypass(host: str) -> Any: ... # Undocumented + +if sys.platform == "win32" or sys.platform == "darwin": + def proxy_bypass(host: str) -> Any: ... # Undocumented + +else: + def proxy_bypass(host: str, proxies: Optional[Mapping[str, str]] = ...) -> Any: ... # Undocumented class Request: @property diff --git a/tests/stubtest_whitelists/darwin.txt b/tests/stubtest_whitelists/darwin.txt index 6c799a963..cb6f25fec 100644 --- a/tests/stubtest_whitelists/darwin.txt +++ b/tests/stubtest_whitelists/darwin.txt @@ -5,10 +5,9 @@ curses.COLOR_PAIRS # Initialized after start_color curses.COLS # Initialized only after initscr call. curses.LINES # Initialized only after initscr call. distutils.command.bdist_msi # msi is only available on windows -grp.getgrgid -grp.struct_group._asdict -grp.struct_group._make -grp.struct_group._replace +grp.struct_group._asdict # PyStructSequence +grp.struct_group._make # PyStructSequence +grp.struct_group._replace # PyStructSequence os.EX_NOTFOUND os.SF_MNOWAIT os.SF_NODISKIO @@ -20,7 +19,6 @@ readline.append_history_file # not defined in macos select.KQ_FILTER_NETDEV # system dependent select.kqueue.__init__ # default C signature is wrong select.POLLMSG # system dependent -socket.socketpair # ========== # Whitelist entries that cannot or should not be fixed @@ -38,7 +36,7 @@ winsound ossaudiodev spwd -# NamedTuple like, but not actually NamedTuples +# NamedTuple like, but not actually NamedTuples (PyStructSequence) posix.[a-z]+_(param|result)._(asdict|make|replace) # Platform differences that cannot be captured by the type system diff --git a/tests/stubtest_whitelists/linux.txt b/tests/stubtest_whitelists/linux.txt index de717150a..febf363b7 100644 --- a/tests/stubtest_whitelists/linux.txt +++ b/tests/stubtest_whitelists/linux.txt @@ -5,10 +5,9 @@ curses.COLOR_PAIRS # Initialized after start_color curses.COLS # Initialized only after initscr call. curses.LINES # Initialized only after initscr call. distutils.command.bdist_msi # msi is only available on windows -grp.getgrgid -grp.struct_group._asdict -grp.struct_group._make -grp.struct_group._replace +grp.struct_group._asdict # PyStructSequence +grp.struct_group._make # PyStructSequence +grp.struct_group._replace # PyStructSequence os.EX_NOTFOUND os.SF_MNOWAIT os.SF_NODISKIO @@ -22,12 +21,9 @@ select.EPOLL_RDHUP selectors.KqueueSelector signal.SIGEMT signal.SIGINFO -socket.socketpair -spwd.getspnam -spwd.struct_spwd._asdict -spwd.struct_spwd._make -spwd.struct_spwd._replace -urllib.request.proxy_bypass +spwd.struct_spwd._asdict # PyStructSequence +spwd.struct_spwd._make # PyStructSequence +spwd.struct_spwd._replace # PyStructSequence # ========== # Whitelist entries that cannot or should not be fixed @@ -43,7 +39,7 @@ msvcrt winreg winsound -# NamedTuple like, but not actually NamedTuples +# NamedTuple like, but not actually NamedTuples (PyStructSequence) posix.[a-z]+_(param|result)._(asdict|make|replace) # Platform differences that cannot be captured by the type system diff --git a/tests/stubtest_whitelists/win32.txt b/tests/stubtest_whitelists/win32.txt index 0f2fdb6cb..8ced5d710 100644 --- a/tests/stubtest_whitelists/win32.txt +++ b/tests/stubtest_whitelists/win32.txt @@ -4,8 +4,6 @@ signal.SIGEMT signal.SIGINFO locale.[A-Z0-9_]+ # Constants that should be moved to _locale and re-exported conditionally locale.nl_langinfo # Function that should be moved to _locale and re-exported conditionally -urllib.request.pathname2url # Parameter name mismatch -urllib.request.url2pathname # Same # ========== # Whitelist entries that cannot or should not be fixed