Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync typeshed #14598

Merged
merged 4 commits into from
Feb 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
1 change: 0 additions & 1 deletion mypy/typeshed/LICENSE
Original file line number Diff line number Diff line change
@@ -235,4 +235,3 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

= = = = =

40 changes: 20 additions & 20 deletions mypy/typeshed/stdlib/_bisect.pyi
Original file line number Diff line number Diff line change
@@ -8,67 +8,67 @@ _T = TypeVar("_T")
if sys.version_info >= (3, 10):
@overload
def bisect_left(
a: Sequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = ..., hi: int | None = ..., *, key: None = ...
a: Sequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None, *, key: None = None
) -> int: ...
@overload
def bisect_left(
a: Sequence[_T],
x: SupportsRichComparisonT,
lo: int = ...,
hi: int | None = ...,
lo: int = 0,
hi: int | None = None,
*,
key: Callable[[_T], SupportsRichComparisonT] = ...,
key: Callable[[_T], SupportsRichComparisonT],
) -> int: ...
@overload
def bisect_right(
a: Sequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = ..., hi: int | None = ..., *, key: None = ...
a: Sequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None, *, key: None = None
) -> int: ...
@overload
def bisect_right(
a: Sequence[_T],
x: SupportsRichComparisonT,
lo: int = ...,
hi: int | None = ...,
lo: int = 0,
hi: int | None = None,
*,
key: Callable[[_T], SupportsRichComparisonT] = ...,
key: Callable[[_T], SupportsRichComparisonT],
) -> int: ...
@overload
def insort_left(
a: MutableSequence[SupportsRichComparisonT],
x: SupportsRichComparisonT,
lo: int = ...,
hi: int | None = ...,
lo: int = 0,
hi: int | None = None,
*,
key: None = ...,
key: None = None,
) -> None: ...
@overload
def insort_left(
a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsRichComparisonT] = ...
a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT]
) -> None: ...
@overload
def insort_right(
a: MutableSequence[SupportsRichComparisonT],
x: SupportsRichComparisonT,
lo: int = ...,
hi: int | None = ...,
lo: int = 0,
hi: int | None = None,
*,
key: None = ...,
key: None = None,
) -> None: ...
@overload
def insort_right(
a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsRichComparisonT] = ...
a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT]
) -> None: ...

else:
def bisect_left(
a: Sequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = ..., hi: int | None = ...
a: Sequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None
) -> int: ...
def bisect_right(
a: Sequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = ..., hi: int | None = ...
a: Sequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None
) -> int: ...
def insort_left(
a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = ..., hi: int | None = ...
a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None
) -> None: ...
def insort_right(
a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = ..., hi: int | None = ...
a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None
) -> None: ...
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_bootlocale.pyi
Original file line number Diff line number Diff line change
@@ -1 +1 @@
def getpreferredencoding(do_setlocale: bool = ...) -> str: ...
def getpreferredencoding(do_setlocale: bool = True) -> str: ...
100 changes: 51 additions & 49 deletions mypy/typeshed/stdlib/_codecs.pyi
Original file line number Diff line number Diff line change
@@ -45,92 +45,94 @@ _BytesToBytesEncoding: TypeAlias = Literal[
_StrToStrEncoding: TypeAlias = Literal["rot13", "rot_13"]

@overload
def encode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = ...) -> bytes: ...
def encode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ...
@overload
def encode(obj: str, encoding: _StrToStrEncoding, errors: str = ...) -> str: ... # type: ignore[misc]
def encode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ... # type: ignore[misc]
@overload
def encode(obj: str, encoding: str = ..., errors: str = ...) -> bytes: ...
def encode(obj: str, encoding: str = "utf-8", errors: str = "strict") -> bytes: ...
@overload
def decode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = ...) -> bytes: ... # type: ignore[misc]
def decode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ... # type: ignore[misc]
@overload
def decode(obj: str, encoding: _StrToStrEncoding, errors: str = ...) -> str: ...
def decode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ...

# these are documented as text encodings but in practice they also accept str as input
@overload
def decode(
obj: str, encoding: Literal["unicode_escape", "unicode-escape", "raw_unicode_escape", "raw-unicode-escape"], errors: str = ...
obj: str,
encoding: Literal["unicode_escape", "unicode-escape", "raw_unicode_escape", "raw-unicode-escape"],
errors: str = "strict",
) -> str: ...

# hex is officially documented as a bytes to bytes encoding, but it appears to also work with str
@overload
def decode(obj: str, encoding: Literal["hex", "hex_codec"], errors: str = ...) -> bytes: ...
def decode(obj: str, encoding: Literal["hex", "hex_codec"], errors: str = "strict") -> bytes: ...
@overload
def decode(obj: ReadableBuffer, encoding: str = ..., errors: str = ...) -> str: ...
def decode(obj: ReadableBuffer, encoding: str = "utf-8", errors: str = "strict") -> str: ...
def lookup(__encoding: str) -> codecs.CodecInfo: ...
def charmap_build(__map: str) -> _CharMap: ...
def ascii_decode(__data: ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def ascii_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def charmap_decode(__data: ReadableBuffer, __errors: str | None = ..., __mapping: _CharMap | None = ...) -> tuple[str, int]: ...
def charmap_encode(__str: str, __errors: str | None = ..., __mapping: _CharMap | None = ...) -> tuple[bytes, int]: ...
def escape_decode(__data: str | ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def escape_encode(__data: bytes, __errors: str | None = ...) -> tuple[bytes, int]: ...
def latin_1_decode(__data: ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def latin_1_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def ascii_decode(__data: ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...
def ascii_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def charmap_decode(__data: ReadableBuffer, __errors: str | None = None, __mapping: _CharMap | None = None) -> tuple[str, int]: ...
def charmap_encode(__str: str, __errors: str | None = None, __mapping: _CharMap | None = None) -> tuple[bytes, int]: ...
def escape_decode(__data: str | ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...
def escape_encode(__data: bytes, __errors: str | None = None) -> tuple[bytes, int]: ...
def latin_1_decode(__data: ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...
def latin_1_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...

if sys.version_info >= (3, 9):
def raw_unicode_escape_decode(
__data: str | ReadableBuffer, __errors: str | None = ..., __final: bool = ...
__data: str | ReadableBuffer, __errors: str | None = None, __final: bool = True
) -> tuple[str, int]: ...

else:
def raw_unicode_escape_decode(__data: str | ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def raw_unicode_escape_decode(__data: str | ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...

def raw_unicode_escape_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def readbuffer_encode(__data: str | ReadableBuffer, __errors: str | None = ...) -> tuple[bytes, int]: ...
def raw_unicode_escape_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def readbuffer_encode(__data: str | ReadableBuffer, __errors: str | None = None) -> tuple[bytes, int]: ...

if sys.version_info >= (3, 9):
def unicode_escape_decode(
__data: str | ReadableBuffer, __errors: str | None = ..., __final: bool = ...
__data: str | ReadableBuffer, __errors: str | None = None, __final: bool = True
) -> tuple[str, int]: ...

else:
def unicode_escape_decode(__data: str | ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def unicode_escape_decode(__data: str | ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...

def unicode_escape_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def unicode_escape_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...

if sys.version_info < (3, 8):
def unicode_internal_decode(__obj: str | ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def unicode_internal_encode(__obj: str | ReadableBuffer, __errors: str | None = ...) -> tuple[bytes, int]: ...
def unicode_internal_decode(__obj: str | ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...
def unicode_internal_encode(__obj: str | ReadableBuffer, __errors: str | None = None) -> tuple[bytes, int]: ...

def utf_16_be_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_16_be_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_16_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_16_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> tuple[bytes, int]: ...
def utf_16_be_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def utf_16_be_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def utf_16_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def utf_16_encode(__str: str, __errors: str | None = None, __byteorder: int = 0) -> tuple[bytes, int]: ...
def utf_16_ex_decode(
__data: ReadableBuffer, __errors: str | None = ..., __byteorder: int = ..., __final: int = ...
__data: ReadableBuffer, __errors: str | None = None, __byteorder: int = 0, __final: int = False
) -> tuple[str, int, int]: ...
def utf_16_le_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_16_le_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_32_be_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_32_be_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_32_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_32_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> tuple[bytes, int]: ...
def utf_16_le_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def utf_16_le_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def utf_32_be_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def utf_32_be_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def utf_32_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def utf_32_encode(__str: str, __errors: str | None = None, __byteorder: int = 0) -> tuple[bytes, int]: ...
def utf_32_ex_decode(
__data: ReadableBuffer, __errors: str | None = ..., __byteorder: int = ..., __final: int = ...
__data: ReadableBuffer, __errors: str | None = None, __byteorder: int = 0, __final: int = False
) -> tuple[str, int, int]: ...
def utf_32_le_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_32_le_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_7_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_7_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_8_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_8_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_32_le_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def utf_32_le_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def utf_7_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def utf_7_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def utf_8_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def utf_8_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...

if sys.platform == "win32":
def mbcs_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def mbcs_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def mbcs_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def mbcs_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def code_page_decode(
__codepage: int, __data: ReadableBuffer, __errors: str | None = ..., __final: int = ...
__codepage: int, __data: ReadableBuffer, __errors: str | None = None, __final: int = False
) -> tuple[str, int]: ...
def code_page_encode(__code_page: int, __str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def oem_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def oem_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def code_page_encode(__code_page: int, __str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def oem_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def oem_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_collections_abc.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from types import MappingProxyType
from typing import ( # noqa: Y027,Y038
from typing import ( # noqa: Y022,Y038
AbstractSet as Set,
AsyncGenerator as AsyncGenerator,
AsyncIterable as AsyncIterable,
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_compression.pyi
Original file line number Diff line number Diff line change
@@ -21,5 +21,5 @@ class DecompressReader(RawIOBase):
**decomp_args: Any,
) -> None: ...
def readinto(self, b: WriteableBuffer) -> int: ...
def read(self, size: int = ...) -> bytes: ...
def seek(self, offset: int, whence: int = ...) -> int: ...
def read(self, size: int = -1) -> bytes: ...
def seek(self, offset: int, whence: int = 0) -> int: ...
30 changes: 15 additions & 15 deletions mypy/typeshed/stdlib/_curses.pyi
Original file line number Diff line number Diff line change
@@ -274,7 +274,7 @@ if sys.platform != "win32":
def baudrate() -> int: ...
def beep() -> None: ...
def can_change_color() -> bool: ...
def cbreak(__flag: bool = ...) -> None: ...
def cbreak(__flag: bool = True) -> None: ...
def color_content(__color_number: int) -> tuple[int, int, int]: ...
# Changed in Python 3.8.8 and 3.9.2
if sys.version_info >= (3, 8):
@@ -287,7 +287,7 @@ if sys.platform != "win32":
def def_shell_mode() -> None: ...
def delay_output(__ms: int) -> None: ...
def doupdate() -> None: ...
def echo(__flag: bool = ...) -> None: ...
def echo(__flag: bool = True) -> None: ...
def endwin() -> None: ...
def erasechar() -> bytes: ...
def filter() -> None: ...
@@ -323,7 +323,7 @@ if sys.platform != "win32":
def napms(__ms: int) -> int: ...
def newpad(__nlines: int, __ncols: int) -> _CursesWindow: ...
def newwin(__nlines: int, __ncols: int, __begin_y: int = ..., __begin_x: int = ...) -> _CursesWindow: ...
def nl(__flag: bool = ...) -> None: ...
def nl(__flag: bool = True) -> None: ...
def nocbreak() -> None: ...
def noecho() -> None: ...
def nonl() -> None: ...
@@ -332,8 +332,8 @@ if sys.platform != "win32":
def pair_content(__pair_number: int) -> tuple[int, int]: ...
def pair_number(__attr: int) -> int: ...
def putp(__string: ReadOnlyBuffer) -> None: ...
def qiflush(__flag: bool = ...) -> None: ...
def raw(__flag: bool = ...) -> None: ...
def qiflush(__flag: bool = True) -> None: ...
def raw(__flag: bool = True) -> None: ...
def reset_prog_mode() -> None: ...
def reset_shell_mode() -> None: ...
def resetty() -> None: ...
@@ -345,7 +345,7 @@ if sys.platform != "win32":
def set_tabsize(__size: int) -> None: ...

def setsyx(__y: int, __x: int) -> None: ...
def setupterm(term: str | None = ..., fd: int = ...) -> None: ...
def setupterm(term: str | None = None, fd: int = -1) -> None: ...
def start_color() -> None: ...
def termattrs() -> int: ...
def termname() -> bytes: ...
@@ -354,15 +354,15 @@ if sys.platform != "win32":
def tigetstr(__capname: str) -> bytes | None: ...
def tparm(
__str: ReadOnlyBuffer,
__i1: int = ...,
__i2: int = ...,
__i3: int = ...,
__i4: int = ...,
__i5: int = ...,
__i6: int = ...,
__i7: int = ...,
__i8: int = ...,
__i9: int = ...,
__i1: int = 0,
__i2: int = 0,
__i3: int = 0,
__i4: int = 0,
__i5: int = 0,
__i6: int = 0,
__i7: int = 0,
__i8: int = 0,
__i9: int = 0,
) -> bytes: ...
def typeahead(__fd: int) -> None: ...
def unctrl(__ch: _ChType) -> bytes: ...
Loading