diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index 1a596b95a..ad4f74357 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -82,8 +82,10 @@ def decode(obj: str, encoding: Literal["rot13", "rot_13"] = ..., errors: str = . @overload def decode(obj: _Encoded, encoding: str = ..., errors: str = ...) -> _Decoded: ... def lookup(__encoding: str) -> CodecInfo: ... -def utf_16_be_decode(__obj: _Encoded, __errors: str = ..., __final: bool = ...) -> Tuple[_Decoded, int]: ... # undocumented -def utf_16_be_encode(__obj: _Decoded, __errors: str = ...) -> Tuple[_Encoded, int]: ... # undocumented +def utf_16_be_decode( + __data: _Encoded, __errors: Optional[str] = ..., __final: bool = ... +) -> Tuple[_Decoded, int]: ... # undocumented +def utf_16_be_encode(__str: _Decoded, __errors: Optional[str] = ...) -> Tuple[_Encoded, int]: ... # undocumented class CodecInfo(Tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]): @property @@ -160,7 +162,7 @@ class IncrementalEncoder: errors: str def __init__(self, errors: str = ...) -> None: ... @abstractmethod - def encode(self, object: _Decoded, final: bool = ...) -> _Encoded: ... + def encode(self, input: _Decoded, final: bool = ...) -> _Encoded: ... def reset(self) -> None: ... # documentation says int but str is needed for the subclass. def getstate(self) -> Union[int, _Decoded]: ... @@ -188,7 +190,7 @@ class BufferedIncrementalDecoder(IncrementalDecoder): def __init__(self, errors: str = ...) -> None: ... @abstractmethod def _buffer_decode(self, input: _Encoded, errors: str, final: bool) -> Tuple[_Decoded, int]: ... - def decode(self, object: _Encoded, final: bool = ...) -> _Decoded: ... + def decode(self, input: _Encoded, final: bool = ...) -> _Decoded: ... _SW = TypeVar("_SW", bound=StreamWriter) @@ -197,14 +199,14 @@ _SW = TypeVar("_SW", bound=StreamWriter) class StreamWriter(Codec): errors: str def __init__(self, stream: IO[_Encoded], errors: str = ...) -> None: ... - def write(self, obj: _Decoded) -> None: ... + def write(self, object: _Decoded) -> None: ... def writelines(self, list: Iterable[_Decoded]) -> None: ... def reset(self) -> None: ... def __enter__(self: _SW) -> _SW: ... def __exit__( self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType] ) -> None: ... - def __getattr__(self, name: str) -> Any: ... + def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... _SR = TypeVar("_SR", bound=StreamReader) @@ -212,15 +214,15 @@ class StreamReader(Codec): errors: str def __init__(self, stream: IO[_Encoded], errors: str = ...) -> None: ... def read(self, size: int = ..., chars: int = ..., firstline: bool = ...) -> _Decoded: ... - def readline(self, size: int = ..., keepends: bool = ...) -> _Decoded: ... - def readlines(self, sizehint: int = ..., keepends: bool = ...) -> List[_Decoded]: ... + def readline(self, size: Optional[int] = ..., keepends: bool = ...) -> _Decoded: ... + def readlines(self, sizehint: Optional[int] = ..., keepends: bool = ...) -> List[_Decoded]: ... def reset(self) -> None: ... def __enter__(self: _SR) -> _SR: ... def __exit__( self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType] ) -> None: ... def __iter__(self) -> Iterator[_Decoded]: ... - def __getattr__(self, name: str) -> Any: ... + def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... _T = TypeVar("_T", bound=StreamReaderWriter) diff --git a/tests/stubtest_whitelists/py36.txt b/tests/stubtest_whitelists/py36.txt index d76c12b05..b454d8ad8 100644 --- a/tests/stubtest_whitelists/py36.txt +++ b/tests/stubtest_whitelists/py36.txt @@ -13,7 +13,6 @@ asyncio.threads # Added in Python 3.9 asyncio.trsock # Added in Python 3.8 builtins.str.maketrans cmath.log -codecs.StreamRecoder.seek collections.AsyncGenerator.ag_await collections.AsyncGenerator.ag_code collections.AsyncGenerator.ag_frame diff --git a/tests/stubtest_whitelists/py3_common.txt b/tests/stubtest_whitelists/py3_common.txt index cd6f93bbc..4dd34ace9 100644 --- a/tests/stubtest_whitelists/py3_common.txt +++ b/tests/stubtest_whitelists/py3_common.txt @@ -85,21 +85,13 @@ bz2.BZ2File.writelines cgi.FieldStorage.__init__ cgi.parse cgi.parse_multipart -codecs.BufferedIncrementalDecoder.decode +# The following CodecInfo properties are added in __new__ codecs.CodecInfo.decode codecs.CodecInfo.encode codecs.CodecInfo.incrementaldecoder codecs.CodecInfo.incrementalencoder codecs.CodecInfo.streamreader codecs.CodecInfo.streamwriter -codecs.IncrementalEncoder.encode -codecs.StreamReader.__getattr__ -codecs.StreamReader.readline -codecs.StreamReader.readlines -codecs.StreamWriter.__getattr__ -codecs.StreamWriter.write -codecs.utf_16_be_decode -codecs.utf_16_be_encode collections.Callable collections.ChainMap.get collections.ChainMap.maps