8000 Sync typeshed by JukkaL · Pull Request #12321 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Sync typeshed #12321

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

Merged
merged 7 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Sync typeshed
  • Loading branch information
JukkaL committed Apr 6, 2022
commit 262b6704918bf6aec5b4f873f69feaed0cef6d67
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/@python2/SocketServer.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from socket import SocketType
from typing import Any, BinaryIO, Callable, ClassVar, Text, Union
from typing import Any, BinaryIO, Callable, ClassVar, Text

class BaseServer:
address_family: int
Expand Down
27 changes: 14 additions & 13 deletions mypy/typeshed/stdlib/@python2/__builtin__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ from typing import (
BinaryIO,
ByteString,
Callable,
ClassVar,
Container,
Generic,
ItemsView,
Expand Down Expand Up @@ -69,8 +70,8 @@ class object:
def __setattr__(self, name: str, value: Any) -> None: ...
def __eq__(self, o: object) -> bool: ...
def __ne__(self, o: object) -> bool: ...
def __str__(self) -> str: ... # noqa Y029
def __repr__(self) -> str: ... # noqa Y029
def __str__(self) -> str: ... # noqa: Y029
def __repr__(self) -> str: ... # noqa: Y029
def __hash__(self) -> int: ...
def __format__(self, format_spec: str) -> str: ...
def __getattribute__(self, name: str) -> Any: ...
Expand Down Expand Up @@ -336,7 +337,7 @@ class unicode(basestring, Sequence[unicode]):
def __ge__(self, x: unicode) -> bool: ...
def __len__(self) -> int: ...
# The argument type is incompatible with Sequence
def __contains__(self, s: unicode | bytes) -> bool: ... # type: ignore
def __contains__(self, s: unicode | bytes) -> bool: ... # type: ignore[override]
def __iter__(self) -> Iterator[unicode]: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
Expand Down Expand Up @@ -414,7 +415,7 @@ class str(Sequence[str], basestring):
def zfill(self, __width: int) -> str: ...
def __add__(self, s: AnyStr) -> AnyStr: ...
# Incompatible with Sequence.__contains__
def __contains__(self, o: str | Text) -> bool: ... # type: ignore
def __contains__(self, o: str | Text) -> bool: ... # type: ignore[override]
def __eq__(self, x: object) -> bool: ...
def __ge__(self, x: Text) -> bool: ...
def __getitem__(self, i: int | slice) -> str: ...
Expand Down Expand Up @@ -490,7 +491,7 @@ class bytearray(MutableSequence[int], ByteString):
def __iter__(self) -> Iterator[int]: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
__hash__: None # type: ignore
__hash__: ClassVar[None] # type: ignore[assignment]
@overload
def __getitem__(self, i: int) -> int: ...
@overload
Expand All @@ -506,7 +507,7 @@ class bytearray(MutableSequence[int], ByteString):
def __add__(self, s: bytes) -> bytearray: ...
def __mul__(self, n: int) -> bytearray: ...
# Incompatible with Sequence.__contains__
def __contains__(self, o: int | bytes) -> bool: ... # type: ignore
def __contains__(self, o: int | bytes) -> bool: ... # type: ignore[override]
def __eq__(self, x: object) -> bool: ...
def __ne__(self, x: object) -> bool: ...
def __lt__(self, x: bytes) -> bool: ...
Expand Down Expand Up @@ -574,7 +575,7 @@ class slice(object):
def __init__(self, stop: Any) -> None: ...
@overload
def __init__(self, start: Any, stop: Any, step: Any = ...) -> None: ...
__hash__: None # type: ignore
__hash__: ClassVar[None] # type: ignore[assignment]
def indices(self, len: int) -> tuple[int, int, int]: ...

class tuple(Sequence[_T_co], Generic[_T_co]):
Expand Down Expand Up @@ -621,7 +622,7 @@ class list(MutableSequence[_T], Generic[_T]):
def sort(self, cmp: Callable[[_T, _T], Any] = ..., key: Callable[[_T], Any] = ..., reverse: bool = ...) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
__hash__: None # type: ignore
__hash__: ClassVar[None] # type: ignore[assignment]
@overload
def __getitem__(self, i: int) -> _T: ...
@overload
Expand Down Expand Up @@ -683,7 +684,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
def __setitem__(self, k: _KT, v: _VT) -> None: ...
def __delitem__(self, v: _KT) -> None: ...
def __iter__(self) -> Iterator[_KT]: ...
__hash__: None # type: ignore
__hash__: ClassVar[None] # type: ignore[assignment]

class set(MutableSet[_T], Generic[_T]):
def __init__(self, iterable: Iterable[_T] = ...) -> None: ...
Expand Down Expand Up @@ -725,7 +726,7 @@ class set(MutableSet[_T], Generic[_T]):
def __lt__(self, s: AbstractSet[object]) -> bool: ...
def __ge__(self, s: AbstractSet[object]) -> bool: ...
def __gt__(self, s: AbstractSet[object]) -> bool: ...
__hash__: None # type: ignore
__hash__: ClassVar[None] # type: ignore[assignment]

class frozenset(AbstractSet[_T_co], Generic[_T_co]):
def __init__(self, iterable: Iterable[_T_co] = ...) -> None: ...
Expand Down Expand Up @@ -784,10 +785,10 @@ class property(object):

long = int

class _NotImplementedType(Any): # type: ignore
class _NotImplementedType(Any): # type: ignore[misc]
# A little weird, but typing the __call__ as NotImplemente 48DA d makes the error message
# for NotImplemented() much better
__call__: NotImplemented # type: ignore
__call__: NotImplemented # type: ignore[valid-type]

NotImplemented: _NotImplementedType

Expand Down Expand Up @@ -964,7 +965,7 @@ def pow(__base: _SupportsPow2[_E, _T_co], __exp: _E) -> _T_co: ...
@overload
def pow(__base: _SupportsPow3[_E, _M, _T_co], __exp: _E, __mod: _M) -> _T_co: ...
def quit(code: object = ...) -> NoReturn: ...
def range(__x: int, __y: int = ..., __step: int = ...) -> list[int]: ... # noqa: F811
def range(__x: int, __y: int = ..., __step: int = ...) -> list[int]: ...
def raw_input(__prompt: Any = ...) -> str: ...
@overload
def reduce(__function: Callable[[_T, _S], _T], __iterable: Iterable[_S], __initializer: _T) -> _T: ...
Expand Down
12 changes: 6 additions & 6 deletions mypy/typeshed/stdlib/@python2/_codecs.pyi
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import codecs
import sys
from typing import Any, Callable, Text, Union
from typing import Any, Callable, Text

# For convenience:
_Handler = Callable[[Exception], tuple[Text, int]]
_String = Union[bytes, str]
_Errors = Union[str, Text, None]
_Decodable = Union[bytes, Text]
_Encodable = Union[bytes, Text]
_String = bytes | str
_Errors = str | Text | None
_Decodable = bytes | Text
_Encodable = bytes | Text

# This type is not exposed; it is defined in unicodeobject.c
class _EncodingMap(object):
def size(self) -> int: ...

_MapT = Union[dict[int, int], _EncodingMap]
_MapT = dict[int, int] | _EncodingMap

def register(__search_function: Callable[[str], Any]) -> None: ...
def register_error(__errors: str | Text, __handler: _Handler) -> None: ...
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/@python2/_curses.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import IO, Any, BinaryIO, Union, overload
from typing import IO, Any, BinaryIO, overload

_chtype = Union[str, bytes, int]
_chtype = str | bytes | int

# ACS codes are only initialized after initscr is called
ACS_BBSS: int
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/@python2/_dummy_threading.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from types import FrameType, TracebackType
from typing import Any, Callable, Iterable, Mapping, Optional, Text
from typing import Any, Callable, Iterable, Mapping, Text

# TODO recursive type
_TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]]
_TF = Callable[[FrameType, str, Any], Callable[..., Any] | None]

_PF = Callable[[FrameType, str, Any], None]

Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/@python2/_io.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from _typeshed import Self
from mmap import mmap
from typing import IO, Any, BinaryIO, Iterable, Text, TextIO, Union
from typing import IO, Any, BinaryIO, Iterable, Text, TextIO

_bytearray_like = Union[bytearray, mmap]
_bytearray_like = bytearray | mmap

DEFAULT_BUFFER_SIZE: int

Expand Down
16 changes: 8 additions & 8 deletions mypy/typeshed/stdlib/@python2/_msi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ if sys.platform == "win32":
def Modify(self, mode: int, record: _Record) -> None: ...
def Close(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
__new__: None # type: ignore[assignment]
__init__: None # type: ignore[assignment]
# Actual typename Summary, not exposed by the implementation
class _Summary:
def GetProperty(self, propid: int) -> str | bytes | None: ...
def GetPropertyCount(self) -> int: ...
def SetProperty(self, propid: int, value: str | bytes) -> None: ...
def Persist(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
__new__: None # type: ignore[assignment]
__init__: None # type: ignore[assignment]
# Actual typename Database, not exposed by the implementation
class _Database:
def OpenView(self, sql: str) -> _View: ...
def Commit(self) -> None: ...
def GetSummaryInformation(self, updateCount: int) -> _Summary: ...
def Close(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
__new__: None # type: ignore[assignment]
__init__: None # type: ignore[assignment]
# Actual typename Record, not exposed by the implementation
class _Record:
def GetFieldCount(self) -> int: ...
Expand All @@ -40,8 +40,8 @@ if sys.platform == "win32":
def SetInteger(self, field: int, int: int) -> None: ...
def ClearData(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
__new__: None # type: ignore[assignment]
__init__: None # type: ignore[assignment]
def UuidCreate() -> str: ...
def FCICreate(cabname: str, files: list[str]) -> None: ...
def OpenDatabase(name: str, flags: int) -> _Database: ...
Expand Down
14 changes: 7 additions & 7 deletions mypy/typeshed/stdlib/@python2/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import array
import mmap
from typing import Any, Container, Iterable, Protocol, Text, TypeVar, Union
from typing import Any, Container, Iterable, Protocol, Text, TypeVar
from typing_extensions import Literal, final

_KT = TypeVar("_KT")
Expand All @@ -28,7 +28,7 @@ _T_contra = TypeVar("_T_contra", contravariant=True)

# Use for "self" annotations:
# def __enter__(self: Self) -> Self: ...
Self = TypeVar("Self") # noqa Y001
Self = TypeVar("Self") # noqa: Y001

class IdentityFunction(Protocol):
def __call__(self, __x: _T) -> _T: ...
Expand Down Expand Up @@ -104,7 +104,7 @@ OpenTextModeUpdating = Literal[
]
OpenTextModeWriting = Literal["w", "wt", "tw", "a", "at", "ta", "x", "xt", "tx"]
OpenTextModeReading = Literal["r", "rt", "tr", "U", "rU", "Ur", "rtU", "rUt", "Urt", "trU", "tUr", "Utr"]
OpenTextMode = Union[OpenTextModeUpdating, OpenTextModeWriting, OpenTextModeReading]
OpenTextMode = OpenTextModeUpdating | OpenTextModeWriting | OpenTextModeReading
OpenBinaryModeUpdating = Literal[
"rb+",
"r+b",
Expand Down Expand Up @@ -133,13 +133,13 @@ OpenBinaryModeUpdating = Literal[
]
OpenBinaryModeWriting = Literal["wb", "bw", "ab", "ba", "xb", "bx"]
OpenBinaryModeReading = Literal["rb", "br", "rbU", "rUb", "Urb", "brU", "bUr", "Ubr"]
OpenBinaryMode = Union[OpenBinaryModeUpdating, OpenBinaryModeReading, OpenBinaryModeWriting]
OpenBinaryMode = OpenBinaryModeUpdating | OpenBinaryModeReading | OpenBinaryModeWriting

class HasFileno(Protocol):
def fileno(self) -> int: ...

FileDescriptor = int
FileDescriptorLike = Union[int, HasFileno]
FileDescriptorLike = int | HasFileno

class SupportsRead(Protocol[_T_co]):
def read(self, __length: int = ...) -> _T_co: ...
Expand All @@ -153,8 +153,8 @@ class SupportsNoArgReadline(Protocol[_T_co]):
class SupportsWrite(Protocol[_T_contra]):
def write(self, __s: _T_contra) -> Any: ...

ReadableBuffer = Union[bytes, bytearray, memoryview, array.array[Any], mmap.mmap, buffer]
WriteableBuffer = Union[bytearray, memoryview, array.array[Any], mmap.mmap, buffer]
ReadableBuffer = bytes | bytearray | memoryview | array.array[Any] | mmap.mmap | buffer
WriteableBuffer = bytearray | memoryview | array.array[Any] | mmap.mmap | buffer

# Used by type checkers for checks involving None (does not exist at runtime)
@final
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/@python2/_typeshed/wsgi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# file. They are provided for type checking purposes.

from sys import _OptExcInfo
from typing import Any, Callable, Iterable, Optional, Protocol, Text
from typing import Any, Callable, Iterable, Protocol, Text

class StartResponse(Protocol):
def __call__(
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/@python2/_winreg.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import sys
from _typeshed import Self
from types import TracebackType
from typing import Any, Union
from typing import Any

if sys.platform == "win32":
_KeyType = Union[HKEYType, int]
_KeyType = HKEYType | int
def CloseKey(__hkey: _KeyType) -> None: ...
def ConnectRegistry(__computer_name: str | None, __key: _KeyType) -> HKEYType: ...
def CreateKey(__key: _KeyType, __sub_key: str | None) -> HKEYType: ...
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/@python2/aifc.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import IO, Any, NamedTuple, Text, Union, overload
from typing import IO, Any, NamedTuple, Text, overload
from typing_extensions import Literal

class Error(Exception): ...
Expand All @@ -11,7 +11,7 @@ class _aifc_params(NamedTuple):
comptype: bytes
compname: bytes

_File = Union[Text, IO[bytes]]
_File = Text | IO[bytes]
_Marker = tuple[int, int, bytes]

class Aifc_read:
Expand Down
8 changes: 4 additions & 4 deletions mypy/typeshed/stdlib/@python2/argparse.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import IO, Any, Callable, Generator, Iterable, NoReturn, Pattern, Protocol, Sequence, Text, TypeVar, Union, overload
from typing import IO, Any, Callable, Generator, Iterable, NoReturn, Pattern, Protocol, Sequence, Text, TypeVar, overload

_T = TypeVar("_T")
_ActionT = TypeVar("_ActionT", bound=Action)
_N = TypeVar("_N")

_Text = Union[str, unicode]
_Text = str | unicode

ONE_OR_MORE: str
OPTIONAL: str
Expand Down Expand Up @@ -107,11 +107,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
@overload
def parse_args(self, args: Sequence[Text] | None = ...) -> Namespace: ...
@overload
def parse_args(self, args: Sequence[Text] | None, namespace: None) -> Namespace: ... # type: ignore
def parse_args(self, args: Sequence[Text] | None, namespace: None) -> Namespace: ... # type: ignore[misc]
@overload
def parse_args(self, args: Sequence[Text] | None, namespace: _N) -> _N: ...
@overload
def parse_args(self, *, namespace: None) -> Namespace: ... # type: ignore
def parse_args(self, *, namespace: None) -> Namespace: ... # type: ignore[misc]
@overload
def parse_args(self, *, namespace: _N) -> _N: ...
def add_subparsers(
Expand Down
8 changes: 4 additions & 4 deletions mypy/typeshed/stdlib/@python2/array.pyi
106C7
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from _typeshed import Self
from typing import Any, BinaryIO, Generic, Iterable, MutableSequence, Text, TypeVar, Union, overload
from typing import Any, BinaryIO, Generic, Iterable, MutableSequence, Text, TypeVar, overload
from typing_extensions import Literal

_IntTypeCode = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"]
_FloatTypeCode = Literal["f", "d"]
_UnicodeTypeCode = Literal["u"]
_TypeCode = Union[_IntTypeCode, _FloatTypeCode, _UnicodeTypeCode]
_TypeCode = _IntTypeCode | _FloatTypeCode | _UnicodeTypeCode

_T = TypeVar("_T", int, float, Text)

Expand All @@ -28,7 +28,7 @@ class array(MutableSequence[_T], Generic[_T]):
def fromfile(self, __f: BinaryIO, __n: int) -> None: ...
def fromlist(self, __list: list[_T]) -> None: ...
def fromunicode(self, __ustr: str) -> None: ...
def index(self, __v: _T) -> int: ... # type: ignore # Overrides Sequence
def index(self, __v: _T) -> int: ... # Overrides Sequence
def insert(self, __i: int, __v: _T) -> None: ...
def pop(self, __i: int = ...) -> _T: ...
def read(self, f: BinaryIO, n: int) -> None: ...
Expand All @@ -45,7 +45,7 @@ class array(MutableSequence[_T], Generic[_T]):
def __getitem__(self, i: int) -> _T: ...
@overload
def __getitem__(self, s: slice) -> array[_T]: ...
@overload # type: ignore # Overrides MutableSequence
@overload # type: ignore[override]
def __setitem__(self, i: int, o: _T) -> None: ...
@overload
def __setitem__(self, s: slice, o: array[_T]) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/@python2/asyncore.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from _typeshed import FileDescriptorLike
from socket import SocketType
from typing import Any, Optional, overload
from typing import Any, overload

# cyclic dependence with asynchat
_maptype = dict[int, Any]
Expand Down
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/@python2/base64.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import IO, Union
from typing import IO

_encodable = Union[bytes, unicode]
_decodable = Union[bytes, unicode]
_encodable = bytes | unicode
_decodable = bytes | unicode

def b64encode(s: _encodable, altchars: bytes | None = ...) -> bytes: ...
def b64decode(s: _decodable, altchars: bytes | None = ..., validate: bool = ...) -> bytes: ...
Expand Down
Loading
0