diff --git a/stdlib/__future__.pyi b/stdlib/__future__.pyi index 0483e736f..8a5035271 100644 --- a/stdlib/__future__.pyi +++ b/stdlib/__future__.pyi @@ -2,6 +2,7 @@ import sys from typing import List class _Feature: + def __init__(self, optionalRelease: sys._version_info, mandatoryRelease: sys._version_info, compiler_flag: int) -> None: ... def getOptionalRelease(self) -> sys._version_info: ... def getMandatoryRelease(self) -> sys._version_info: ... compiler_flag: int diff --git a/stdlib/dbm/__init__.pyi b/stdlib/dbm/__init__.pyi index 2b870b38e..edce1ea02 100644 --- a/stdlib/dbm/__init__.pyi +++ b/stdlib/dbm/__init__.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Iterator, MutableMapping, Optional, Type, Union +from typing import Iterator, MutableMapping, Optional, Tuple, Type, Union from typing_extensions import Literal _KeyType = Union[str, bytes] @@ -18,7 +18,9 @@ class _Database(MutableMapping[_KeyType, bytes]): self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> None: ... -class error(Exception): ... +class _error(Exception): ... + +error = Tuple[Type[_error], Type[OSError]] def whichdb(filename: str) -> str: ... def open(file: str, flag: Literal["r", "w", "c", "n"] = ..., mode: int = ...) -> _Database: ... diff --git a/stdlib/encodings/utf_8.pyi b/stdlib/encodings/utf_8.pyi index 67e139c88..96a156c79 100644 --- a/stdlib/encodings/utf_8.pyi +++ b/stdlib/encodings/utf_8.pyi @@ -1,15 +1,21 @@ import codecs -from typing import Tuple +from typing import Optional, Tuple class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input: str, final: bool = ...) -> bytes: ... class IncrementalDecoder(codecs.BufferedIncrementalDecoder): - def _buffer_decode(self, input: bytes, errors: str, final: bool) -> Tuple[str, int]: ... + @staticmethod + def _buffer_decode(__data: bytes, __errors: Optional[str] = ..., __final: bool = ...) -> Tuple[str, int]: ... -class StreamWriter(codecs.StreamWriter): ... -class StreamReader(codecs.StreamReader): ... +class StreamWriter(codecs.StreamWriter): + @staticmethod + def encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... + +class StreamReader(codecs.StreamReader): + @staticmethod + def decode(__data: bytes, __errors: Optional[str] = ..., __final: bool = ...) -> Tuple[str, int]: ... def getregentry() -> codecs.CodecInfo: ... -def encode(input: str, errors: str = ...) -> bytes: ... -def decode(input: bytes, errors: str = ...) -> str: ... +def encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... +def decode(input: bytes, errors: Optional[str] = ...) -> Tuple[str, int]: ... diff --git a/stdlib/getopt.pyi b/stdlib/getopt.pyi index 3f4b9211c..6ae226f52 100644 --- a/stdlib/getopt.pyi +++ b/stdlib/getopt.pyi @@ -4,5 +4,6 @@ def gnu_getopt(args: list[str], shortopts: str, longopts: list[str] = ...) -> tu class GetoptError(Exception): msg: str opt: str + def __init__(self, msg: str, opt: str = ...) -> None: ... error = GetoptError diff --git a/tests/stubtest_whitelists/py3_common.txt b/tests/stubtest_whitelists/py3_common.txt index 98214a4c0..5ca43be0c 100644 --- a/tests/stubtest_whitelists/py3_common.txt +++ b/tests/stubtest_whitelists/py3_common.txt @@ -1,4 +1,3 @@ -__future__._Feature.__init__ _collections_abc.Callable _collections_abc.Coroutine.cr_await _collections_abc.Coroutine.cr_code @@ -21,7 +20,7 @@ _collections_abc.MutableSet.remove _collections_abc.Sequence.count _collections_abc.Sequence.index _collections_abc.Set.isdisjoint -_csv.Dialect.__init__ +_csv.Dialect.__init__ # C __init__ signature is inaccurate _dummy_threading _importlib_modulespec _threading_local.local.__new__ @@ -131,22 +130,16 @@ ctypes.memset # CFunctionType ctypes.pointer # imported C function ctypes.string_at # docstring argument name is wrong ctypes.wstring_at # docstring argument name is wrong -dbm.error difflib.SequenceMatcher.__init__ # mypy default value for generic parameter issues. See https://github.com/python/mypy/issues/3737 distutils.command.bdist_packager # It exists in docs as package name but not in code except as a mention in a comment. distutils.version.Version._cmp # class should have declared this distutils.version.Version.parse # class should have declared this email.headerregistry.BaseHeader.max_count # docs say subclasses should have this property -encodings.utf_8.IncrementalDecoder._buffer_decode -encodings.utf_8.StreamReader.decode -encodings.utf_8.StreamWriter.encode -encodings.utf_8.encode enum.EnumMeta.__call__ enum.EnumMeta.__new__ -getopt.GetoptError.__init__ http.HTTPStatus.description # set in __new__ http.HTTPStatus.phrase # set in __new__ -imaplib.IMAP4_SSL.ssl +imaplib.IMAP4_SSL.ssl # Dependent on SSL existence importlib.abc.FileLoader.get_filename # Wrapped with _check_name decorator which changes runtime signature importlib.abc.FileLoader.load_module # Wrapped with _check_name decorator which changes runtime signature importlib.abc.Loader.exec_module # See Lib/importlib/_abc.py. Might be defined for backwards compatability