Skip to content

Commit ffd78df

Browse files
authored
Sync typeshed (#13742)
Source commit: python/typeshed@9abe56a
1 parent 50ac875 commit ffd78df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+538
-526
lines changed

mypy/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
import sys
4949
from io import StringIO
50-
from typing import Callable, TextIO
50+
from typing import Callable, TextIO, cast
5151

5252

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

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

mypy/typeshed/stdlib/VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ _collections_abc: 3.3-
2727
_compat_pickle: 3.1-
2828
_compression: 3.5-
2929
_csv: 2.7-
30+
_ctypes: 2.7-
3031
_curses: 2.7-
3132
_decimal: 3.3-
3233
_dummy_thread: 3.0-3.8

mypy/typeshed/stdlib/_ast.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class Import(stmt):
194194
class ImportFrom(stmt):
195195
if sys.version_info >= (3, 10):
196196
__match_args__ = ("module", "names", "level")
197-
module: _Identifier | None
197+
module: str | None
198198
names: list[alias]
199199
level: int
200200

mypy/typeshed/stdlib/_ctypes.pyi

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import sys
2+
from ctypes import _CArgObject, _PointerLike
3+
from typing_extensions import TypeAlias
4+
5+
FUNCFLAG_CDECL: int
6+
FUNCFLAG_PYTHONAPI: int
7+
FUNCFLAG_USE_ERRNO: int
8+
FUNCFLAG_USE_LASTERROR: int
9+
RTLD_GLOBAL: int
10+
RTLD_LOCAL: int
11+
12+
if sys.version_info >= (3, 11):
13+
CTYPES_MAX_ARGCOUNT: int
14+
15+
if sys.platform == "win32":
16+
# Description, Source, HelpFile, HelpContext, scode
17+
_COMError_Details: TypeAlias = tuple[str | None, str | None, str | None, int | None, int | None]
18+
19+
class COMError(Exception):
20+
hresult: int
21+
text: str | None
22+
details: _COMError_Details
23+
24+
def __init__(self, hresult: int, text: str | None, details: _COMError_Details) -> None: ...
25+
26+
def CopyComPointer(src: _PointerLike, dst: _PointerLike | _CArgObject) -> int: ...
27+
28+
FUNCFLAG_HRESULT: int
29+
FUNCFLAG_STDCALL: int

mypy/typeshed/stdlib/_socket.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ class socket:
624624
__buffers: Iterable[ReadableBuffer],
625625
__ancdata: Iterable[_CMSGArg] = ...,
626626
__flags: int = ...,
627-
__address: _Address = ...,
627+
__address: _Address | None = ...,
628628
) -> int: ...
629629
if sys.platform == "linux":
630630
def sendmsg_afalg(

mypy/typeshed/stdlib/_typeshed/__init__.pyi

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import ctypes
77
import mmap
88
import pickle
99
import sys
10-
from collections.abc import Awaitable, Callable, Container, Iterable, Set as AbstractSet
10+
from collections.abc import Awaitable, Callable, Iterable, Set as AbstractSet
1111
from os import PathLike
1212
from types import FrameType, TracebackType
1313
from typing import Any, AnyStr, Generic, Protocol, TypeVar, Union
@@ -115,16 +115,17 @@ class SupportsItems(Protocol[_KT_co, _VT_co]):
115115
# stable
116116
class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]):
117117
def keys(self) -> Iterable[_KT]: ...
118-
def __getitem__(self, __k: _KT) -> _VT_co: ...
118+
def __getitem__(self, __key: _KT) -> _VT_co: ...
119119

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

124125
# stable
125126
class SupportsItemAccess(SupportsGetItem[_KT_contra, _VT], Protocol[_KT_contra, _VT]):
126-
def __setitem__(self, __k: _KT_contra, __v: _VT) -> None: ...
127-
def __delitem__(self, __v: _KT_contra) -> None: ...
127+
def __setitem__(self, __key: _KT_contra, __value: _VT) -> None: ...
128+
def __delitem__(self, __key: _KT_contra) -> None: ...
128129

129130
StrPath: TypeAlias = str | PathLike[str] # stable
130131
BytesPath: TypeAlias = bytes | PathLike[bytes] # stable

mypy/typeshed/stdlib/argparse.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,10 @@ class _StoreFalseAction(_StoreConstAction):
399399
# undocumented
400400
class _AppendAction(Action): ...
401401

402+
# undocumented
403+
if sys.version_info >= (3, 8):
404+
class _ExtendAction(_AppendAction): ...
405+
402406
# undocumented
403407
class _AppendConstAction(Action):
404408
if sys.version_info >= (3, 11):

mypy/typeshed/stdlib/asyncio/transports.pyi

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from asyncio.events import AbstractEventLoop
22
from asyncio.protocols import BaseProtocol
3-
from collections.abc import Mapping
3+
from collections.abc import Iterable, Mapping
44
from socket import _Address
55
from typing import Any
66

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

99
class BaseTransport:
10-
def __init__(self, extra: Mapping[Any, Any] | None = ...) -> None: ...
11-
def get_extra_info(self, name: Any, default: Any = ...) -> Any: ...
10+
def __init__(self, extra: Mapping[str, Any] | None = ...) -> None: ...
11+
def get_extra_info(self, name: str, default: Any = ...) -> Any: ...
1212
def is_closing(self) -> bool: ...
1313
def close(self) -> None: ...
1414
def set_protocol(self, protocol: BaseProtocol) -> None: ...
@@ -23,16 +23,16 @@ class WriteTransport(BaseTransport):
2323
def set_write_buffer_limits(self, high: int | None = ..., low: int | None = ...) -> None: ...
2424
def get_write_buffer_size(self) -> int: ...
2525
def get_write_buffer_limits(self) -> tuple[int, int]: ...
26-
def write(self, data: Any) -> None: ...
27-
def writelines(self, list_of_data: list[Any]) -> None: ...
26+
def write(self, data: bytes) -> None: ...
27+
def writelines(self, list_of_data: Iterable[bytes]) -> None: ...
2828
def write_eof(self) -> None: ...
2929
def can_write_eof(self) -> bool: ...
3030
def abort(self) -> None: ...
3131

3232
class Transport(ReadTransport, WriteTransport): ...
3333

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

3838
class SubprocessTransport(BaseTransport):
@@ -44,4 +44,4 @@ class SubprocessTransport(BaseTransport):
4444
def kill(self) -> None: ...
4545

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

0 commit comments

Comments
 (0)