diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index 7039e3da9..b47b56bb7 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -82,26 +82,37 @@ else: def __delitem__(self, index: Union[int, slice]) -> None: ... def __setitem__(self, index: Union[int, slice], object: bytes) -> None: ... -if sys.version_info >= (3, 8): +if sys.version_info >= (3, 8) and sys.platform != "win32": MADV_NORMAL: int MADV_RANDOM: int MADV_SEQUENTIAL: int MADV_WILLNEED: int MADV_DONTNEED: int - MADV_REMOVE: int - MADV_DONTFORK: int - MADV_DOFORK: int - MADV_HWPOISON: int - MADV_MERGEABLE: int - MADV_UNMERGEABLE: int - MADV_SOFT_OFFLINE: int - MADV_HUGEPAGE: int - MADV_NOHUGEPAGE: int - MADV_DONTDUMP: int - MADV_DODUMP: int - MADV_FREE: int - MADV_NOSYNC: int - MADV_AUTOSYNC: int - MADV_NOCORE: int - MADV_CORE: int - MADV_PROTECT: int + + if sys.platform == "linux": + MADV_REMOVE: int + MADV_DONTFORK: int + MADV_DOFORK: int + MADV_HWPOISON: int + MADV_MERGEABLE: int + MADV_UNMERGEABLE: int + # Seems like this constant is not defined in glibc. + # See https://github.com/python/typeshed/pull/5360 for details + # MADV_SOFT_OFFLINE: int + MADV_HUGEPAGE: int + MADV_NOHUGEPAGE: int + MADV_DONTDUMP: int + MADV_DODUMP: int + MADV_FREE: int + + # This Values are defined for FreeBSD but type checkers do not support conditions for these + if sys.platform != "linux" and sys.platform != "darwin": + MADV_NOSYNC: int + MADV_AUTOSYNC: int + MADV_NOCORE: int + MADV_CORE: int + MADV_PROTECT: int + +if sys.version_info >= (3, 10) and sys.platform == "darwin": + MADV_FREE_REUSABLE: int + MADV_FREE_REUSE: int diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index bed840c00..7ead36e90 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -97,7 +97,6 @@ class BaseHandler: parent: OpenerDirector def add_parent(self, parent: OpenerDirector) -> None: ... def close(self) -> None: ... - def http_error_nnn(self, req: Request, fp: IO[str], code: int, msg: int, headers: Mapping[str, str]) -> _UrlopenRet: ... class HTTPDefaultErrorHandler(BaseHandler): def http_error_default( diff --git a/stdlib/urllib/robotparser.pyi b/stdlib/urllib/robotparser.pyi index ad96ca12b..382dcee0e 100644 --- a/stdlib/urllib/robotparser.pyi +++ b/stdlib/urllib/robotparser.pyi @@ -10,7 +10,7 @@ class RobotFileParser: def set_url(self, url: str) -> None: ... def read(self) -> None: ... def parse(self, lines: Iterable[str]) -> None: ... - def can_fetch(self, user_agent: str, url: str) -> bool: ... + def can_fetch(self, useragent: str, url: str) -> bool: ... def mtime(self) -> int: ... def modified(self) -> None: ... def crawl_delay(self, useragent: str) -> Optional[str]: ... diff --git a/stdlib/webbrowser.pyi b/stdlib/webbrowser.pyi index 00e3f9f26..322ec2764 100644 --- a/stdlib/webbrowser.pyi +++ b/stdlib/webbrowser.pyi @@ -48,7 +48,6 @@ class UnixBrowser(BaseBrowser): def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... class Mozilla(UnixBrowser): - raise_opts: List[str] remote_args: List[str] remote_action: str remote_action_newwin: str diff --git a/tests/stubtest_whitelists/py310.txt b/tests/stubtest_whitelists/py310.txt index 7374686f5..bc3918ae8 100644 --- a/tests/stubtest_whitelists/py310.txt +++ b/tests/stubtest_whitelists/py310.txt @@ -64,7 +64,6 @@ logging.handlers.TimedRotatingFileHandler.__init__ logging.handlers.WatchedFileHandler.__init__ macpath # module removed in 3.8 macurl2path # module removed in 3.7 -mmap.MADV_[A-Z_]+ # platform dependent constants multiprocessing.spawn._main os.getgrouplist os.sendfile diff --git a/tests/stubtest_whitelists/py38.txt b/tests/stubtest_whitelists/py38.txt index 927dec351..6d9ba1b29 100644 --- a/tests/stubtest_whitelists/py38.txt +++ b/tests/stubtest_whitelists/py38.txt @@ -34,7 +34,6 @@ collections.abc.AsyncGenerator.ag_running collections.abc.ItemsView.__reversed__ collections.abc.KeysView.__reversed__ collections.abc.ValuesView.__reversed__ -concurrent.futures.ProcessPoolExecutor.map contextlib.nullcontext # not a function at runtime contextvars.Context.__init__ # Default C __init__ signature is wrong dataclasses.field @@ -52,7 +51,6 @@ ipaddress._BaseNetwork.broadcast_address ipaddress._BaseNetwork.hostmask macpath # removed in 3.8 macurl2path # removed in 3.7 -mmap.MADV_[A-Z_]+ multiprocessing.spawn._main pickle.Pickler.reducer_override # implemented in C pickler queue.SimpleQueue.__init__ # Default C __init__ signature is wrong diff --git a/tests/stubtest_whitelists/py39.txt b/tests/stubtest_whitelists/py39.txt index 58a4c3223..939e3996d 100644 --- a/tests/stubtest_whitelists/py39.txt +++ b/tests/stubtest_whitelists/py39.txt @@ -73,7 +73,6 @@ logging.handlers.TimedRotatingFileHandler.__init__ logging.handlers.WatchedFileHandler.__init__ macpath # module removed in 3.8 macurl2path # module removed in 3.7 -mmap.MADV_[A-Z_]+ # platform dependent constants multiprocessing.spawn._main os.MFD_HUGE_32MB os.MFD_HUGE_512MB diff --git a/tests/stubtest_whitelists/py3_common.txt b/tests/stubtest_whitelists/py3_common.txt index 37559610b..bdf9a7f8f 100644 --- a/tests/stubtest_whitelists/py3_common.txt +++ b/tests/stubtest_whitelists/py3_common.txt @@ -208,9 +208,7 @@ typing.IO.__next__ # Added because IO streams are iterable. See https://github. typing.type_check_only # typing decorator that is not available at runtime unittest.mock.patch # It's a complicated overload and I haven't been able to figure out why stubtest doesn't like it urllib.parse._DefragResultBase.__new__ # Generic NamedTuple is problematic in mypy, so regular tuple was used. See https://github.com/python/mypy/issues/685 -urllib.request.BaseHandler.http_error_nnn -urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ -urllib.robotparser.RobotFileParser.can_fetch +urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to super, so super args are specified warnings.catch_warnings.__init__ # Defining this ruins the __new__ overrides weakref.CallableProxyType.__getattr__ # Should have all attributes of proxy weakref.ProxyType.__getattr__ # Should have all attributes of proxy @@ -218,11 +216,9 @@ weakref.ReferenceType.__call__ # C function default annotation is wrong weakref.WeakKeyDictionary.get weakref.WeakKeyDictionary.update weakref.WeakValueDictionary.get -webbrowser.Mozilla.raise_opts -webbrowser.UnixBrowser.raise_opts -webbrowser.UnixBrowser.remote_action -webbrowser.UnixBrowser.remote_action_newtab -webbrowser.UnixBrowser.remote_action_newwin +webbrowser.UnixBrowser.remote_action # always overridden in inheriting class +webbrowser.UnixBrowser.remote_action_newtab # always overridden in inheriting class +webbrowser.UnixBrowser.remote_action_newwin # always overridden in inheriting class wsgiref.types # Doesn't exist, see comments in file # ==========