diff --git a/stdlib/contextvars.pyi b/stdlib/contextvars.pyi index 810b699b6..069a67866 100644 --- a/stdlib/contextvars.pyi +++ b/stdlib/contextvars.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, TypeVar, Union, overload +from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, Optional, TypeVar, Union, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -35,6 +35,10 @@ def copy_context() -> Context: ... # a different value. class Context(Mapping[ContextVar[Any], Any]): def __init__(self) -> None: ... + @overload + def get(self, __key: ContextVar[Any]) -> Optional[Any]: ... + @overload + def get(self, __key: ContextVar[Any], __default: Optional[Any]) -> Any: ... def run(self, callable: Callable[..., _T], *args: Any, **kwargs: Any) -> _T: ... def copy(self) -> Context: ... def __getitem__(self, key: ContextVar[Any]) -> Any: ... diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index 2f6b2df08..c35228928 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -183,18 +183,33 @@ class HTTPConnection: def send(self, data: _DataType) -> None: ... class HTTPSConnection(HTTPConnection): - def __init__( - self, - host: str, - port: Optional[int] = ..., - key_file: Optional[str] = ..., - cert_file: Optional[str] = ..., - timeout: Optional[float] = ..., - source_address: Optional[Tuple[str, int]] = ..., - *, - context: Optional[ssl.SSLContext] = ..., - check_hostname: Optional[bool] = ..., - ) -> None: ... + if sys.version_info >= (3, 7): + def __init__( + self, + host: str, + port: Optional[int] = ..., + key_file: Optional[str] = ..., + cert_file: Optional[str] = ..., + timeout: Optional[float] = ..., + source_address: Optional[Tuple[str, int]] = ..., + *, + context: Optional[ssl.SSLContext] = ..., + check_hostname: Optional[bool] = ..., + blocksize: int = ..., + ) -> None: ... + else: + def __init__( + self, + host: str, + port: Optional[int] = ..., + key_file: Optional[str] = ..., + cert_file: Optional[str] = ..., + timeout: Optional[float] = ..., + source_address: Optional[Tuple[str, int]] = ..., + *, + context: Optional[ssl.SSLContext] = ..., + check_hostname: Optional[bool] = ..., + ) -> None: ... class HTTPException(Exception): ... diff --git a/stdlib/http/cookiejar.pyi b/stdlib/http/cookiejar.pyi index a57c7c0fb..9398bae00 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -63,21 +63,39 @@ class DefaultCookiePolicy(CookiePolicy): DomainRFC2965Match: int DomainLiberal: int DomainStrict: int - def __init__( - self, - blocked_domains: Optional[Sequence[str]] = ..., - allowed_domains: Optional[Sequence[str]] = ..., - netscape: bool = ..., - rfc2965: bool = ..., - rfc2109_as_netscape: Optional[bool] = ..., - hide_cookie2: bool = ..., - strict_domain: bool = ..., - strict_rfc2965_unverifiable: bool = ..., - strict_ns_unverifiable: bool = ..., - strict_ns_domain: int = ..., - strict_ns_set_initial_dollar: bool = ..., - strict_ns_set_path: bool = ..., - ) -> None: ... + if sys.version_info >= (3, 8): + def __init__( + self, + blocked_domains: Optional[Sequence[str]] = ..., + allowed_domains: Optional[Sequence[str]] = ..., + netscape: bool = ..., + rfc2965: bool = ..., + rfc2109_as_netscape: Optional[bool] = ..., + hide_cookie2: bool = ..., + strict_domain: bool = ..., + strict_rfc2965_unverifiable: bool = ..., + strict_ns_unverifiable: bool = ..., + strict_ns_domain: int = ..., + strict_ns_set_initial_dollar: bool = ..., + strict_ns_set_path: bool = ..., + secure_protocols: Sequence[str] = ..., + ) -> None: ... + else: + def __init__( + self, + blocked_domains: Optional[Sequence[str]] = ..., + allowed_domains: Optional[Sequence[str]] = ..., + netscape: bool = ..., + rfc2965: bool = ..., + rfc2109_as_netscape: Optional[bool] = ..., + hide_cookie2: bool = ..., + strict_domain: bool = ..., + strict_rfc2965_unverifiable: bool = ..., + strict_ns_unverifiable: bool = ..., + strict_ns_domain: int = ..., + strict_ns_set_initial_dollar: bool = ..., + strict_ns_set_path: bool = ..., + ) -> None: ... def blocked_domains(self) -> Tuple[str, ...]: ... def set_blocked_domains(self, blocked_domains: Sequence[str]) -> None: ... def is_blocked(self, domain: str) -> bool: ... diff --git a/stdlib/nntplib.pyi b/stdlib/nntplib.pyi index 7e7b7b84c..36fe063c8 100644 --- a/stdlib/nntplib.pyi +++ b/stdlib/nntplib.pyi @@ -82,7 +82,7 @@ class _NNTPBase: def ihave(self, message_id: Any, data: Union[bytes, Iterable[bytes]]) -> str: ... def quit(self) -> str: ... def login(self, user: Optional[str] = ..., password: Optional[str] = ..., usenetrc: bool = ...) -> None: ... - def starttls(self, ssl_context: Optional[ssl.SSLContext] = ...) -> None: ... + def starttls(self, context: Optional[ssl.SSLContext] = ...) -> None: ... class NNTP(_NNTPBase): port: int diff --git a/stdlib/platform.pyi b/stdlib/platform.pyi index 73579dff3..217882224 100644 --- a/stdlib/platform.pyi +++ b/stdlib/platform.pyi @@ -1,6 +1,6 @@ import sys -if sys.version_info < (3, 9): +if sys.version_info < (3, 8): import os DEV_NULL = os.devnull diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index 4f376d2b6..48a35f8e3 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -2,7 +2,7 @@ from email.message import Message as _Message from socket import socket from ssl import SSLContext from types import TracebackType -from typing import Any, Dict, List, Optional, Pattern, Protocol, Sequence, Tuple, Type, Union, overload +from typing import Any, Dict, Optional, Pattern, Protocol, Sequence, Tuple, Type, Union, overload _Reply = Tuple[int, bytes] _SendErrs = Dict[str, _Reply] @@ -117,7 +117,7 @@ class SMTP: to_addrs: Union[str, Sequence[str]], msg: Union[bytes, str], mail_options: Sequence[str] = ..., - rcpt_options: List[str] = ..., + rcpt_options: Sequence[str] = ..., ) -> _SendErrs: ... def send_message( self, diff --git a/stdlib/sre_constants.pyi b/stdlib/sre_constants.pyi index d66f19eda..07a308e6f 100644 --- a/stdlib/sre_constants.pyi +++ b/stdlib/sre_constants.pyi @@ -1,3 +1,4 @@ +import sys from typing import Any, Dict, List, Optional, Union MAGIC: int @@ -72,7 +73,10 @@ REPEAT: _NamedIntConstant REPEAT_ONE: _NamedIntConstant SUBPATTERN: _NamedIntConstant MIN_REPEAT_ONE: _NamedIntConstant -RANGE_IGNORE: _NamedIntConstant +if sys.version_info >= (3, 7): + RANGE_UNI_IGNORE: _NamedIntConstant +else: + RANGE_IGNORE: _NamedIntConstant MIN_REPEAT: _NamedIntConstant MAX_REPEAT: _NamedIntConstant diff --git a/stdlib/webbrowser.pyi b/stdlib/webbrowser.pyi index e29238ee0..00e3f9f26 100644 --- a/stdlib/webbrowser.pyi +++ b/stdlib/webbrowser.pyi @@ -38,7 +38,7 @@ class BackgroundBrowser(GenericBrowser): def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... class UnixBrowser(BaseBrowser): - raise_opts: List[str] + raise_opts: Optional[List[str]] background: bool redirect_stdout: bool remote_args: List[str] @@ -70,7 +70,6 @@ class Chrome(UnixBrowser): background: bool class Opera(UnixBrowser): - raise_opts: List[str] remote_args: List[str] remote_action: str remote_action_newwin: str diff --git a/tests/stubtest_whitelists/linux-py37.txt b/tests/stubtest_whitelists/linux-py37.txt index 6754d36e8..5043392b3 100644 --- a/tests/stubtest_whitelists/linux-py37.txt +++ b/tests/stubtest_whitelists/linux-py37.txt @@ -1,4 +1,4 @@ ctypes.wintypes pwd.getpwnam time.CLOCK_PROF -time.CLOCK_UPTIME +time.CLOCK_UPTIME \ No newline at end of file diff --git a/tests/stubtest_whitelists/linux-py38.txt b/tests/stubtest_whitelists/linux-py38.txt index 3eeef9f7d..86693b859 100644 --- a/tests/stubtest_whitelists/linux-py38.txt +++ b/tests/stubtest_whitelists/linux-py38.txt @@ -2,4 +2,4 @@ ctypes.wintypes os.MFD_HUGE_32MB os.MFD_HUGE_512MB time.CLOCK_PROF -time.CLOCK_UPTIME +time.CLOCK_UPTIME \ No newline at end of file diff --git a/tests/stubtest_whitelists/py310.txt b/tests/stubtest_whitelists/py310.txt index 4a43e760d..7374686f5 100644 --- a/tests/stubtest_whitelists/py310.txt +++ b/tests/stubtest_whitelists/py310.txt @@ -38,9 +38,7 @@ collections.abc.ItemsView.__reversed__ collections.abc.KeysView.__reversed__ collections.abc.ValuesView.__reversed__ contextlib.nullcontext # not a function at runtime -contextvars.Context.__init__ -contextvars.Context.get -copy.PyStringMap +contextvars.Context.__init__ # Default C __init__ signature is wrong curses.color_pair dataclasses.field dummy_threading @@ -53,9 +51,7 @@ functools.singledispatchmethod.__call__ gettext.install gettext.translation hmac.new # Stub is a white lie; see comments in the stub -http.client.HTTPSConnection.__init__ -http.cookiejar.DefaultCookiePolicy.__init__ -http.server.SimpleHTTPRequestHandler.__init__ +http.server.SimpleHTTPRequestHandler.__init__ # *args is expanded importlib.abc.Traversable.__init__ # Inherits __init__ from typing.Protocol ipaddress.IPv4Interface.hostmask ipaddress.IPv6Interface.hostmask @@ -70,19 +66,16 @@ macpath # module removed in 3.8 macurl2path # module removed in 3.7 mmap.MADV_[A-Z_]+ # platform dependent constants multiprocessing.spawn._main -nntplib.NNTP.starttls os.getgrouplist os.sendfile -pickle.Pickler.reducer_override +pickle.Pickler.reducer_override # implemented in C pickler # platform.uname_result's processor field is now dynamically made to exist platform.uname_result.__new__ platform.uname_result._fields platform.uname_result.processor -queue.SimpleQueue.__init__ +queue.SimpleQueue.__init__ # Default C __init__ signature is wrong select.epoll.register smtplib.LMTP.__init__ -smtplib.SMTP.sendmail -sre_constants.RANGE_IGNORE ssl.PROTOCOL_SSLv3 # Depends on ssl compilation ssl.RAND_egd # Depends on openssl compilation symtable.SymbolTable.has_exec @@ -114,7 +107,6 @@ typing._TypedDict.setdefault typing._TypedDict.update typing._TypedDict.values weakref.WeakValueDictionary.update -webbrowser.Opera.raise_opts xml.etree.ElementTree.XMLParser.__init__ # Defined in C so has general signature xml.etree.cElementTree.XMLParser.__init__ # Defined in C so has general signature diff --git a/tests/stubtest_whitelists/py36.txt b/tests/stubtest_whitelists/py36.txt index 0f45e2d3d..0cc5d181c 100644 --- a/tests/stubtest_whitelists/py36.txt +++ b/tests/stubtest_whitelists/py36.txt @@ -20,7 +20,6 @@ collections.AsyncGenerator.ag_frame collections.AsyncGenerator.ag_running collections.UserString.maketrans contextlib._GeneratorContextManager.__init__ -copy.PyStringMap enum.Enum._generate_next_value_ fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve hmac.HMAC.__init__ @@ -31,7 +30,6 @@ ipaddress._BaseNetwork.__init__ json.loads mmap.ACCESS_DEFAULT multiprocessing.shared_memory -nntplib._NNTPBase.starttls os.utime plistlib.Dict.__init__ pyexpat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args @@ -39,7 +37,6 @@ random.Random.randrange # missing undocumented arg _int random.randrange # missing undocumented arg _int sched.Event.__doc__ # __slots__ is overridden secrets.SystemRandom.getstate -smtplib.SMTP.sendmail sre_compile.dis typing.AsyncGenerator.ag_await typing.AsyncGenerator.ag_code @@ -67,7 +64,6 @@ unittest.async_case # Added in Python 3.8 urllib.parse.parse_qs urllib.parse.parse_qsl uuid.UUID.int -webbrowser.Opera.raise_opts xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modules, fixed in bpo-39495 xml.etree.cElementTree.TreeBuilder.start # bpo-39495 xml.parsers.expat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args diff --git a/tests/stubtest_whitelists/py37.txt b/tests/stubtest_whitelists/py37.txt index 7f154e7e8..c0b51b0e5 100644 --- a/tests/stubtest_whitelists/py37.txt +++ b/tests/stubtest_whitelists/py37.txt @@ -25,32 +25,26 @@ collections.abc.AsyncGenerator.ag_code collections.abc.AsyncGenerator.ag_frame collections.abc.AsyncGenerator.ag_running concurrent.futures.ProcessPoolExecutor.map -contextvars.Context.__init__ -contextvars.Context.get +contextvars.Context.__init__ # Default C __init__ signature is wrong contextvars.ContextVar.get contextlib.nullcontext # not a function at runtime -copy.PyStringMap dataclasses.field enum.Enum._generate_next_value_ fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve hmac.HMAC.__init__ -http.client.HTTPSConnection.__init__ -http.server.SimpleHTTPRequestHandler.__init__ +http.server.SimpleHTTPRequestHandler.__init__ # *args is expanded importlib.metadata # Added in 3.8 ipaddress._BaseNetwork.__init__ json.loads macurl2path # removed in 3.7 multiprocessing.shared_memory -nntplib._NNTPBase.starttls os.utime pyexpat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args -queue.SimpleQueue.__init__ +queue.SimpleQueue.__init__ # Default C __init__ signature is wrong random.Random.randrange # missing undocumented arg _int random.randrange # missing undocumented arg _int sched.Event.__doc__ # __slots__ is overridden secrets.SystemRandom.getstate -smtplib.SMTP.sendmail -sre_constants.RANGE_IGNORE ssl.PROTOCOL_SSLv3 # Depends on ssl compilation ssl.RAND_egd # Depends on openssl compilation types.ClassMethodDescriptorType.__get__ @@ -68,7 +62,6 @@ urllib.parse.parse_qsl uuid.UUID.int uuid.UUID.is_safe uuid.getnode # undocumented, unused parameter getters that was later removed -webbrowser.Opera.raise_opts xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modules, fixed in bpo-39495 xml.etree.cElementTree.TreeBuilder.start # bpo-39495 xml.parsers.expat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args diff --git a/tests/stubtest_whitelists/py38.txt b/tests/stubtest_whitelists/py38.txt index 370f32cdd..927dec351 100644 --- a/tests/stubtest_whitelists/py38.txt +++ b/tests/stubtest_whitelists/py38.txt @@ -5,10 +5,6 @@ _collections_abc.AsyncGenerator.ag_running _collections_abc.ItemsView.__reversed__ _collections_abc.KeysView.__reversed__ _collections_abc.ValuesView.__reversed__ -# This was changed in Python 3.8.8. -_curses.color_pair -_thread.ExceptHookArgs -_thread._ExceptHookArgs ast.Bytes.__new__ ast.Ellipsis.__new__ ast.NameConstant.__new__ @@ -40,41 +36,31 @@ collections.abc.KeysView.__reversed__ collections.abc.ValuesView.__reversed__ concurrent.futures.ProcessPoolExecutor.map contextlib.nullcontext # not a function at runtime -contextvars.Context.__init__ -contextvars.Context.get -copy.PyStringMap -# This was changed in Python 3.8.8. -curses.color_pair +contextvars.Context.__init__ # Default C __init__ signature is wrong dataclasses.field enum.Enum._generate_next_value_ fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve functools.partialmethod.__get__ functools.singledispatchmethod.__call__ # A lie to reflect that the descriptor get returns a callable -gettext.install -gettext.translation +gettext.install # codeset default value is ['unspecified'] so can't be specified +gettext.translation # codeset default value is ['unspecified'] so can't be specified hmac.new # Stub is a white lie; see comments in the stub -http.client.HTTPSConnection.__init__ -http.cookiejar.DefaultCookiePolicy.__init__ -http.server.SimpleHTTPRequestHandler.__init__ +http.server.SimpleHTTPRequestHandler.__init__ # *args is expanded ipaddress.IPv4Interface.hostmask ipaddress.IPv6Interface.hostmask ipaddress._BaseNetwork.broadcast_address ipaddress._BaseNetwork.hostmask -macpath +macpath # removed in 3.8 macurl2path # removed in 3.7 mmap.MADV_[A-Z_]+ multiprocessing.spawn._main -nntplib._NNTPBase.starttls -pickle.Pickler.reducer_override -platform.DEV_NULL -queue.SimpleQueue.__init__ +pickle.Pickler.reducer_override # implemented in C pickler +queue.SimpleQueue.__init__ # Default C __init__ signature is wrong random.Random.randrange # missing undocumented arg _int random.randrange # missing undocumented arg _int sched.Event.__doc__ # __slots__ is overridden secrets.SystemRandom.getstate select.epoll.register -smtplib.SMTP.sendmail -sre_constants.RANGE_IGNORE ssl.PROTOCOL_SSLv3 # Depends on ssl compilation ssl.RAND_egd # Depends on openssl compilation sys.UnraisableHookArgs # Not exported from sys @@ -97,7 +83,6 @@ typing._SpecialForm.__init__ typing._SpecialForm.__new__ uuid.getnode # undocumented, unused parameter getters that was later removed weakref.WeakValueDictionary.update -webbrowser.Opera.raise_opts xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modules, fixed in bpo-39495 xml.etree.ElementTree.XMLParser.__init__ # Defined in C so has general signature xml.etree.cElementTree.TreeBuilder.start # bpo-39495 diff --git a/tests/stubtest_whitelists/py39.txt b/tests/stubtest_whitelists/py39.txt index 50449383c..58a4c3223 100644 --- a/tests/stubtest_whitelists/py39.txt +++ b/tests/stubtest_whitelists/py39.txt @@ -46,9 +46,7 @@ collections.abc.ItemsView.__reversed__ collections.abc.KeysView.__reversed__ collections.abc.ValuesView.__reversed__ contextlib.nullcontext # not a function at runtime -contextvars.Context.__init__ -contextvars.Context.get -copy.PyStringMap +contextvars.Context.__init__ # Default C __init__ signature is wrong curses.color_pair dataclasses.field dataclasses.InitVar.__class_getitem__ # stubtest bug. doesn't do the right thing with overload + implicit classmethod __class_getitem__ @@ -62,9 +60,7 @@ functools.singledispatchmethod.__call__ gettext.install gettext.translation hmac.new # Stub is a white lie; see comments in the stub -http.client.HTTPSConnection.__init__ -http.cookiejar.DefaultCookiePolicy.__init__ -http.server.SimpleHTTPRequestHandler.__init__ +http.server.SimpleHTTPRequestHandler.__init__ # *args is expanded importlib.abc.Traversable.__init__ # Inherits __init__ from typing.Protocol ipaddress.IPv4Interface.hostmask ipaddress.IPv6Interface.hostmask @@ -79,23 +75,20 @@ macpath # module removed in 3.8 macurl2path # module removed in 3.7 mmap.MADV_[A-Z_]+ # platform dependent constants multiprocessing.spawn._main -nntplib.NNTP.starttls os.MFD_HUGE_32MB os.MFD_HUGE_512MB os.getgrouplist os.sendfile -pickle.Pickler.reducer_override +pickle.Pickler.reducer_override # implemented in C pickler # platform.uname_result's processor field is now dynamically made to exist platform.uname_result.__new__ platform.uname_result._fields platform.uname_result.processor -queue.SimpleQueue.__init__ +queue.SimpleQueue.__init__ # Default C __init__ signature is wrong sched.Event.__doc__ # __slots__ is overridden secrets.SystemRandom.getstate select.epoll.register smtplib.LMTP.__init__ -smtplib.SMTP.sendmail -sre_constants.RANGE_IGNORE ssl.PROTOCOL_SSLv3 # Depends on ssl compilation ssl.RAND_egd # Depends on openssl compilation symtable.SymbolTable.has_exec @@ -128,7 +121,6 @@ typing._TypedDict.update typing._TypedDict.values unittest.doModuleCleanups weakref.WeakValueDictionary.update -webbrowser.Opera.raise_opts xml.etree.ElementTree.XMLParser.__init__ # Defined in C so has general signature xml.etree.cElementTree.XMLParser.__init__ # Defined in C so has general signature diff --git a/tests/stubtest_whitelists/py3_common.txt b/tests/stubtest_whitelists/py3_common.txt index 1759fb240..4571f14d9 100644 --- a/tests/stubtest_whitelists/py3_common.txt +++ b/tests/stubtest_whitelists/py3_common.txt @@ -66,6 +66,7 @@ configparser.SectionProxy.__getattr__ # SectionProxy can have arbitrary attribu configparser.SectionProxy.getboolean configparser.SectionProxy.getfloat configparser.SectionProxy.getint +copy.PyStringMap # defined only in Jython # The Dialect properties are initialized as None in Dialect but their values are enforced in _Dialect csv.Dialect.delimiter csv.Dialect.doublequote