Skip to content

Commit

Permalink
Sync typeshed (#11416)
Browse files Browse the repository at this point in the history
Source commit:
python/typeshed@151f256

Co-authored-by: hauntsaninja <>
  • Loading branch information
hauntsaninja authored Oct 31, 2021
1 parent 3d82f6f commit 28d57b1
Show file tree
Hide file tree
Showing 180 changed files with 1,350 additions and 1,194 deletions.
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/@python2/__builtin__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ def min(__iterable: Iterable[_T], *, key: Callable[[_T], Any] = ...) -> _T: ...
@overload
def next(__i: Iterator[_T]) -> _T: ...
@overload
def next(__i: Iterator[_T], default: _VT) -> _T | _VT: ...
def next(__i: Iterator[_T], __default: _VT) -> _T | _VT: ...
def oct(__number: int | _SupportsIndex) -> str: ...
def open(name: unicode | int, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ...
def ord(__c: Text | bytes) -> int: ...
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/@python2/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ def min(__iterable: Iterable[_T], *, key: Callable[[_T], Any] = ...) -> _T: ...
@overload
def next(__i: Iterator[_T]) -> _T: ...
@overload
def next(__i: Iterator[_T], default: _VT) -> _T | _VT: ...
def next(__i: Iterator[_T], __default: _VT) -> _T | _VT: ...
def oct(__number: int | _SupportsIndex) -> str: ...
def open(name: unicode | int, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ...
def ord(__c: Text | bytes) -> int: ...
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/@python2/sqlite3/dbapi2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class Cursor(Iterator[Any]):
description: Any
lastrowid: Any
row_factory: Any
rowcount: Any
rowcount: int
# TODO: Cursor class accepts exactly 1 argument
# required type is sqlite3.Connection (which is imported as _Connection)
# however, the name of the __init__ variable is unknown
Expand Down
78 changes: 39 additions & 39 deletions mypy/typeshed/stdlib/_codecs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,51 @@ def lookup_error(__name: str) -> _Handler: ...
def decode(obj: Any, encoding: str = ..., errors: str | None = ...) -> Any: ...
def encode(obj: Any, encoding: str = ..., errors: str | None = ...) -> Any: ...
def charmap_build(__map: str) -> _MapT: ...
def ascii_decode(__data: bytes, __errors: str | None = ...) -> Tuple[str, int]: ...
def ascii_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def charmap_decode(__data: bytes, __errors: str | None = ..., __mapping: _MapT | None = ...) -> Tuple[str, int]: ...
def charmap_encode(__str: str, __errors: str | None = ..., __mapping: _MapT | None = ...) -> Tuple[bytes, int]: ...
def escape_decode(__data: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ...
def escape_encode(__data: bytes, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def latin_1_decode(__data: bytes, __errors: str | None = ...) -> Tuple[str, int]: ...
def latin_1_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def raw_unicode_escape_decode(__data: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ...
def raw_unicode_escape_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def readbuffer_encode(__data: str | bytes, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def unicode_escape_decode(__data: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ...
def unicode_escape_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def ascii_decode(__data: bytes, __errors: str | None = ...) -> tuple[str, int]: ...
def ascii_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def charmap_decode(__data: bytes, __errors: str | None = ..., __mapping: _MapT | None = ...) -> tuple[str, int]: ...
def charmap_encode(__str: str, __errors: str | None = ..., __mapping: _MapT | None = ...) -> tuple[bytes, int]: ...
def escape_decode(__data: str | bytes, __errors: str | None = ...) -> tuple[str, int]: ...
def escape_encode(__data: bytes, __errors: str | None = ...) -> tuple[bytes, int]: ...
def latin_1_decode(__data: bytes, __errors: str | None = ...) -> tuple[str, int]: ...
def latin_1_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def raw_unicode_escape_decode(__data: str | bytes, __errors: str | None = ...) -> tuple[str, int]: ...
def raw_unicode_escape_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def readbuffer_encode(__data: str | bytes, __errors: str | None = ...) -> tuple[bytes, int]: ...
def unicode_escape_decode(__data: str | bytes, __errors: str | None = ...) -> tuple[str, int]: ...
def unicode_escape_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...

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

def utf_16_be_decode(__data: bytes, __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: bytes, __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: bytes, __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: bytes, __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_ex_decode(
__data: bytes, __errors: str | None = ..., __byteorder: int = ..., __final: int = ...
) -> Tuple[str, int, int]: ...
def utf_16_le_decode(__data: bytes, __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: bytes, __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: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_32_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ...
) -> tuple[str, int, int]: ...
def utf_16_le_decode(__data: bytes, __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: bytes, __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: bytes, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_32_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> tuple[bytes, int]: ...
def utf_32_ex_decode(
__data: bytes, __errors: str | None = ..., __byteorder: int = ..., __final: int = ...
) -> Tuple[str, int, int]: ...
def utf_32_le_decode(__data: bytes, __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: bytes, __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: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_8_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
) -> tuple[str, int, int]: ...
def utf_32_le_decode(__data: bytes, __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: bytes, __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: bytes, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_8_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...

if sys.platform == "win32":
def mbcs_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
def mbcs_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def code_page_decode(__codepage: int, __data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
def code_page_encode(__code_page: int, __str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def oem_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
def oem_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def mbcs_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def mbcs_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def code_page_decode(__codepage: int, __data: bytes, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def code_page_encode(__code_page: int, __str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def oem_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def oem_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_compat_pickle.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import Tuple

IMPORT_MAPPING: dict[str, str]
NAME_MAPPING: dict[Tuple[str, str], Tuple[str, str]]
NAME_MAPPING: dict[tuple[str, str], tuple[str, str]]
PYTHON2_EXCEPTIONS: Tuple[str, ...]
MULTIPROCESSING_EXCEPTIONS: Tuple[str, ...]
REVERSE_IMPORT_MAPPING: dict[str, str]
REVERSE_NAME_MAPPING: dict[Tuple[str, str], Tuple[str, str]]
REVERSE_NAME_MAPPING: dict[tuple[str, str], tuple[str, str]]
PYTHON3_OSERROR_EXCEPTIONS: Tuple[str, ...]
PYTHON3_IMPORTERROR_EXCEPTIONS: Tuple[str, ...]
22 changes: 11 additions & 11 deletions mypy/typeshed/stdlib/_curses.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from typing import IO, Any, BinaryIO, NamedTuple, Tuple, Union, overload
from typing import IO, Any, BinaryIO, NamedTuple, Union, overload

_chtype = Union[str, bytes, int]

Expand Down Expand Up @@ -273,7 +273,7 @@ def baudrate() -> int: ...
def beep() -> None: ...
def can_change_color() -> bool: ...
def cbreak(__flag: bool = ...) -> None: ...
def color_content(__color_number: int) -> Tuple[int, int, int]: ...
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):
Expand All @@ -293,8 +293,8 @@ def erasechar() -> bytes: ...
def filter() -> None: ...
def flash() -> None: ...
def flushinp() -> None: ...
def getmouse() -> Tuple[int, int, int, int, int]: ...
def getsyx() -> Tuple[int, int]: ...
def getmouse() -> tuple[int, int, int, int, int]: ...
def getsyx() -> tuple[int, int]: ...
def getwin(__file: BinaryIO) -> _CursesWindow: ...
def halfdelay(__tenths: int) -> None: ...
def has_colors() -> bool: ...
Expand All @@ -316,7 +316,7 @@ def killchar() -> bytes: ...
def longname() -> bytes: ...
def meta(__yes: bool) -> None: ...
def mouseinterval(__interval: int) -> None: ...
def mousemask(__newmask: int) -> Tuple[int, int]: ...
def mousemask(__newmask: int) -> tuple[int, int]: ...
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: ...
Expand All @@ -326,7 +326,7 @@ def noecho() -> None: ...
def nonl() -> None: ...
def noqiflush() -> None: ...
def noraw() -> None: ...
def pair_content(__pair_number: int) -> Tuple[int, int]: ...
def pair_content(__pair_number: int) -> tuple[int, int]: ...
def pair_number(__attr: int) -> int: ...
def putp(__string: bytes) -> None: ...
def qiflush(__flag: bool = ...) -> None: ...
Expand Down Expand Up @@ -427,8 +427,8 @@ class _CursesWindow:
def echochar(self, __ch: _chtype, __attr: int = ...) -> None: ...
def enclose(self, __y: int, __x: int) -> bool: ...
def erase(self) -> None: ...
def getbegyx(self) -> Tuple[int, int]: ...
def getbkgd(self) -> Tuple[int, int]: ...
def getbegyx(self) -> tuple[int, int]: ...
def getbkgd(self) -> tuple[int, int]: ...
@overload
def getch(self) -> int: ...
@overload
Expand All @@ -441,8 +441,8 @@ class _CursesWindow:
def getkey(self) -> str: ...
@overload
def getkey(self, y: int, x: int) -> str: ...
def getmaxyx(self) -> Tuple[int, int]: ...
def getparyx(self) -> Tuple[int, int]: ...
def getmaxyx(self) -> tuple[int, int]: ...
def getparyx(self) -> tuple[int, int]: ...
@overload
def getstr(self) -> _chtype: ...
@overload
Expand All @@ -451,7 +451,7 @@ class _CursesWindow:
def getstr(self, y: int, x: int) -> _chtype: ...
@overload
def getstr(self, y: int, x: int, n: int) -> _chtype: ...
def getyx(self) -> Tuple[int, int]: ...
def getyx(self) -> tuple[int, int]: ...
@overload
def hline(self, ch: _chtype, n: int) -> None: ...
@overload
Expand Down
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/_json.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Callable, Tuple
from typing import Any, Callable

class make_encoder:
sort_keys: Any
Expand Down Expand Up @@ -32,7 +32,7 @@ class make_scanner:
strict: bool
# TODO: 'context' needs the attrs above (ducktype), but not __call__.
def __init__(self, context: make_scanner) -> None: ...
def __call__(self, string: str, index: int) -> Tuple[Any, int]: ...
def __call__(self, string: str, index: int) -> tuple[Any, int]: ...

def encode_basestring_ascii(s: str) -> str: ...
def scanstring(string: str, end: int, strict: bool = ...) -> Tuple[str, int]: ...
def scanstring(string: str, end: int, strict: bool = ...) -> tuple[str, int]: ...
4 changes: 1 addition & 3 deletions mypy/typeshed/stdlib/_markupbase.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from typing import Tuple

class ParserBase:
def __init__(self) -> None: ...
def error(self, message: str) -> None: ...
def reset(self) -> None: ...
def getpos(self) -> Tuple[int, int]: ...
def getpos(self) -> tuple[int, int]: ...
def unknown_decl(self, data: str) -> None: ...
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_osx_support.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def customize_config_vars(_config_vars: dict[str, str]) -> dict[str, str]: ...
def customize_compiler(_config_vars: dict[str, str]) -> dict[str, str]: ...
def get_platform_osx(
_config_vars: dict[str, str], osname: _T, release: _K, machine: _V
) -> Tuple[str | _T, str | _K, str | _V]: ...
) -> tuple[str | _T, str | _K, str | _V]: ...
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_posixsubprocess.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# NOTE: These are incomplete!

from typing import Callable, Sequence, Tuple
from typing import Callable, Sequence

def cloexec_pipe() -> Tuple[int, int]: ...
def cloexec_pipe() -> tuple[int, int]: ...
def fork_exec(
args: Sequence[str],
executable_list: Sequence[bytes],
Expand Down
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/_socket.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ if sys.platform == "linux" and sys.version_info >= (3, 7):

if sys.platform == "linux" and sys.version_info >= (3, 9):
CAN_J1939: int
CAN_RAW_JOIN_FILTERS: int

J1939_MAX_UNICAST_ADDR: int
J1939_IDLE_ADDR: int
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_threading_local.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Any, Dict, Tuple
from typing import Any, Dict
from weakref import ReferenceType

localdict = Dict[Any, Any]

class _localimpl:
key: str
dicts: dict[int, Tuple[ReferenceType[Any], localdict]]
dicts: dict[int, tuple[ReferenceType[Any], localdict]]
def __init__(self) -> None: ...
def get_dict(self) -> localdict: ...
def create_dict(self) -> localdict: ...
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_tracemalloc.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import sys
from tracemalloc import _FrameTupleT, _TraceTupleT
from typing import Sequence, Tuple
from typing import Sequence

def _get_object_traceback(__obj: object) -> Sequence[_FrameTupleT] | None: ...
def _get_traces() -> Sequence[_TraceTupleT]: ...
def clear_traces() -> None: ...
def get_traceback_limit() -> int: ...
def get_traced_memory() -> Tuple[int, int]: ...
def get_traced_memory() -> tuple[int, int]: ...
def get_tracemalloc_memory() -> int: ...
def is_tracing() -> bool: ...

Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ctypes
import mmap
import sys
from os import PathLike
from typing import AbstractSet, Any, Awaitable, Container, Iterable, Protocol, Tuple, TypeVar, Union
from typing import AbstractSet, Any, Awaitable, Container, Iterable, Protocol, TypeVar, Union
from typing_extensions import Literal, final

_KT = TypeVar("_KT")
Expand Down Expand Up @@ -57,7 +57,7 @@ class SupportsTrunc(Protocol):

# stable
class SupportsItems(Protocol[_KT_co, _VT_co]):
def items(self) -> AbstractSet[Tuple[_KT_co, _VT_co]]: ...
def items(self) -> AbstractSet[tuple[_KT_co, _VT_co]]: ...

# stable
class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]):
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_typeshed/wsgi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# See the README.md file in this directory for more information.

from sys import _OptExcInfo
from typing import Any, Callable, Dict, Iterable, Protocol, Tuple
from typing import Any, Callable, Dict, Iterable, Protocol

# stable
class StartResponse(Protocol):
def __call__(
self, status: str, headers: list[Tuple[str, str]], exc_info: _OptExcInfo | None = ...
self, status: str, headers: list[tuple[str, str]], exc_info: _OptExcInfo | None = ...
) -> Callable[[bytes], Any]: ...

WSGIEnvironment = Dict[str, Any] # stable
Expand Down
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/_warnings.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Tuple, Type, overload
from typing import Any, Type, overload

_defaultaction: str
_onceregistry: dict[Any, Any]
Expand All @@ -15,7 +15,7 @@ def warn_explicit(
filename: str,
lineno: int,
module: str | None = ...,
registry: dict[str | Tuple[str, Type[Warning], int], int] | None = ...,
registry: dict[str | tuple[str, Type[Warning], int], int] | None = ...,
module_globals: dict[str, Any] | None = ...,
source: Any | None = ...,
) -> None: ...
Expand All @@ -26,7 +26,7 @@ def warn_explicit(
filename: str,
lineno: int,
module: str | None = ...,
registry: dict[str | Tuple[str, Type[Warning], int], int] | None = ...,
registry: dict[str | tuple[str, Type[Warning], int], int] | None = ...,
module_globals: dict[str, Any] | None = ...,
source: Any | None = ...,
) -> None: ...
Loading

0 comments on commit 28d57b1

Please sign in to comment.