Skip to content

Sync typeshed #13742

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 2 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions mypy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

import sys
from io import StringIO
from typing import Callable, TextIO
from typing import Callable, TextIO, cast


def _run(main_wrapper: Callable[[TextIO, TextIO], None]) -> tuple[str, str, int]:
Expand All @@ -59,7 +59,7 @@ def _run(main_wrapper: Callable[[TextIO, TextIO], None]) -> tuple[str, str, int]
main_wrapper(stdout, stderr)
exit_status = 0
except SystemExit as system_exit:
exit_status = system_exit.code
exit_status = cast(int, system_exit.code)

return stdout.getvalue(), stderr.getvalue(), exit_status

Expand Down
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ _collections_abc: 3.3-
_compat_pickle: 3.1-
_compression: 3.5-
_csv: 2.7-
_ctypes: 2.7-
_curses: 2.7-
_decimal: 3.3-
_dummy_thread: 3.0-3.8
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_ast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class Import(stmt):
class ImportFrom(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("module", "names", "level")
module: _Identifier | None
module: str | None
names: list[alias]
level: int

Expand Down
29 changes: 29 additions & 0 deletions mypy/typeshed/stdlib/_ctypes.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import sys
from ctypes import _CArgObject, _PointerLike
from typing_extensions import TypeAlias

FUNCFLAG_CDECL: int
FUNCFLAG_PYTHONAPI: int
FUNCFLAG_USE_ERRNO: int
FUNCFLAG_USE_LASTERROR: int
RTLD_GLOBAL: int
RTLD_LOCAL: int

if sys.version_info >= (3, 11):
CTYPES_MAX_ARGCOUNT: int

if sys.platform == "win32":
# Description, Source, HelpFile, HelpContext, scode
_COMError_Details: TypeAlias = tuple[str | None, str | None, str | None, int | None, int | None]

class COMError(Exception):
hresult: int
text: str | None
details: _COMError_Details

def __init__(self, hresult: int, text: str | None, details: _COMError_Details) -> None: ...

def CopyComPointer(src: _PointerLike, dst: _PointerLike | _CArgObject) -> int: ...

FUNCFLAG_HRESULT: int
FUNCFLAG_STDCALL: int
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_socket.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ class socket:
__buffers: Iterable[ReadableBuffer],
__ancdata: Iterable[_CMSGArg] = ...,
__flags: int = ...,
__address: _Address = ...,
__address: _Address | None = ...,
) -> int: ...
if sys.platform == "linux":
def sendmsg_afalg(
Expand Down
13 changes: 7 additions & 6 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 pickle
import sys
from collections.abc import Awaitable, Callable, Container, Iterable, Set as AbstractSet
from collections.abc import Awaitable, Callable, Iterable, Set as AbstractSet
from os import PathLike
from types import FrameType, TracebackType
from typing import Any, AnyStr, Generic, Protocol, TypeVar, Union
Expand Down Expand Up @@ -115,16 +115,17 @@ class SupportsItems(Protocol[_KT_co, _VT_co]):
# stable
class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]):
def keys(self) -> Iterable[_KT]: ...
def __getitem__(self, __k: _KT) -> _VT_co: ...
def __getitem__(self, __key: _KT) -> _VT_co: ...

# stable
class SupportsGetItem(Container[_KT_contra], Protocol[_KT_contra, _VT_co]): # type: ignore
def __getitem__(self, __k: _KT_contra) -> _VT_co: ...
class SupportsGetItem(Protocol[_KT_contra, _VT_co]):
def __contains__(self, __x: object) -> bool: ...
def __getitem__(self, __key: _KT_contra) -> _VT_co: ...

# stable
class SupportsItemAccess(SupportsGetItem[_KT_contra, _VT], Protocol[_KT_contra, _VT]):
def __setitem__(self, __k: _KT_contra, __v: _VT) -> None: ...
def __delitem__(self, __v: _KT_contra) -> None: ...
def __setitem__(self, __key: _KT_contra, __value: _VT) -> None: ...
def __delitem__(self, __key: _KT_contra) -> None: ...

StrPath: TypeAlias = str | PathLike[str] # stable
BytesPath: TypeAlias = bytes | PathLike[bytes] # stable
Expand Down
4 changes: 4 additions & 0 deletions mypy/typeshed/stdlib/argparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ class _StoreFalseAction(_StoreConstAction):
# undocumented
class _AppendAction(Action): ...

# undocumented
if sys.version_info >= (3, 8):
class _ExtendAction(_AppendAction): ...

# undocumented
class _AppendConstAction(Action):
if sys.version_info >= (3, 11):
Expand Down
14 changes: 7 additions & 7 deletions mypy/typeshed/stdlib/asyncio/transports.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from asyncio.events import AbstractEventLoop
from asyncio.protocols import BaseProtocol
from collections.abc import Mapping
from collections.abc import Iterable, Mapping
from socket import _Address
from typing import Any

__all__ = ("BaseTransport", "ReadTransport", "WriteTransport", "Transport", "DatagramTransport", "SubprocessTransport")

class BaseTransport:
def __init__(self, extra: Mapping[Any, Any] | None = ...) -> None: ...
def get_extra_info(self, name: Any, default: Any = ...) -> Any: ...
def __init__(self, extra: Mapping[str, Any] | None = ...) -> None: ...
def get_extra_info(self, name: str, default: Any = ...) -> Any: ...
def is_closing(self) -> bool: ...
def close(self) -> None: ...
def set_protocol(self, protocol: BaseProtocol) -> None: ...
Expand All @@ -23,16 +23,16 @@ class WriteTransport(BaseTransport):
def set_write_buffer_limits(self, high: int | None = ..., low: int | None = ...) -> None: ...
def get_write_buffer_size(self) -> int: ...
def get_write_buffer_limits(self) -> tuple[int, int]: ...
def write(self, data: Any) -> None: ...
def writelines(self, list_of_data: list[Any]) -> None: ...
def write(self, data: bytes) -> None: ...
def writelines(self, list_of_data: Iterable[bytes]) -> None: ...
def write_eof(self) -> None: ...
def can_write_eof(self) -> bool: ...
def abort(self) -> None: ...

class Transport(ReadTransport, WriteTransport): ...

class DatagramTransport(BaseTransport):
def sendto(self, data: Any, addr: _Address | None = ...) -> None: ...
def sendto(self, data: bytes, addr: _Address | None = ...) -> None: ...
def abort(self) -> None: ...

class SubprocessTransport(BaseTransport):
Expand All @@ -44,4 +44,4 @@ class SubprocessTransport(BaseTransport):
def kill(self) -> None: ...

class _FlowControlMixin(Transport):
def __init__(self, extra: Mapping[Any, Any] | None = ..., loop: AbstractEventLoop | None = ...) -> None: ...
def __init__(self, extra: Mapping[str, Any] | None = ..., loop: AbstractEventLoop | None = ...) -> None: ...
Loading