Skip to content

Commit 61f9a0a

Browse files
[ty] Sync vendored typeshed stubs (#24646)
Co-authored-by: typeshedbot <>
1 parent b41cb9a commit 61f9a0a

40 files changed

Lines changed: 224 additions & 125 deletions
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c5e47faeda2cf9d233f91bc1dc95814b0cc7ccba
1+
c03c2b926422c82ab680d27f3ad2491845000802

crates/ty_vendored/vendor/typeshed/stdlib/_codecs.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ def ascii_decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[st
119119
def ascii_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
120120
def charmap_decode(data: ReadableBuffer, errors: str | None = None, mapping: _CharMap | None = None, /) -> tuple[str, int]: ...
121121
def charmap_encode(str: str, errors: str | None = None, mapping: _CharMap | None = None, /) -> tuple[bytes, int]: ...
122-
def escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
122+
123+
# Docs say this accepts a bytes-like object, but in practice it also accepts str.
124+
def escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[bytes, int]: ...
123125
def escape_encode(data: bytes, errors: str | None = None, /) -> tuple[bytes, int]: ...
124126
def latin_1_decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
125127
def latin_1_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...

crates/ty_vendored/vendor/typeshed/stdlib/_operator.pyi

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ used for special methods; variants without leading and trailing
88
"""
99

1010
import sys
11-
from _typeshed import SupportsGetItem
11+
from _typeshed import (
12+
SupportsAdd,
13+
SupportsGetItem,
14+
SupportsMod,
15+
SupportsMul,
16+
SupportsRAdd,
17+
SupportsRMod,
18+
SupportsRMul,
19+
SupportsRSub,
20+
SupportsSub,
21+
)
1222
from collections.abc import Callable, Container, Iterable, MutableMapping, MutableSequence, Sequence
1323
from operator import attrgetter as attrgetter, itemgetter as itemgetter, methodcaller as methodcaller
1424
from typing import Any, AnyStr, Protocol, SupportsAbs, SupportsIndex, TypeVar, overload, type_check_only
@@ -17,6 +27,7 @@ from typing_extensions import ParamSpec, TypeAlias, TypeIs
1727
_R = TypeVar("_R")
1828
_T = TypeVar("_T")
1929
_T_co = TypeVar("_T_co", covariant=True)
30+
_T_contra = TypeVar("_T_contra", contravariant=True)
2031
_K = TypeVar("_K")
2132
_V = TypeVar("_V")
2233
_P = ParamSpec("_P")
@@ -89,13 +100,16 @@ def is_not(a: object, b: object, /) -> bool:
89100
def abs(a: SupportsAbs[_T], /) -> _T:
90101
"""Same as abs(a)."""
91102

92-
def add(a: Any, b: Any, /) -> Any:
103+
@overload
104+
def add(a: SupportsAdd[_T_contra, _T_co], b: _T_contra, /) -> _T_co:
93105
"""Same as a + b."""
94106

95-
def and_(a: Any, b: Any, /) -> Any:
107+
@overload
108+
def add(a: _T_contra, b: SupportsRAdd[_T_contra, _T_co], /) -> _T_co: ...
109+
def and_(a, b, /):
96110
"""Same as a & b."""
97111

98-
def floordiv(a: Any, b: Any, /) -> Any:
112+
def floordiv(a, b, /):
99113
"""Same as a // b."""
100114

101115
def index(a: SupportsIndex, /) -> int:
@@ -107,40 +121,49 @@ def inv(a: _SupportsInversion[_T_co], /) -> _T_co:
107121
def invert(a: _SupportsInversion[_T_co], /) -> _T_co:
108122
"""Same as ~a."""
109123

110-
def lshift(a: Any, b: Any, /) -> Any:
124+
def lshift(a, b, /):
111125
"""Same as a << b."""
112126

113-
def mod(a: Any, b: Any, /) -> Any:
127+
@overload
128+
def mod(a: SupportsMod[_T_contra, _T_co], b: _T_contra, /) -> _T_co:
114129
"""Same as a % b."""
115130

116-
def mul(a: Any, b: Any, /) -> Any:
131+
@overload
132+
def mod(a: _T_contra, b: SupportsRMod[_T_contra, _T_co], /) -> _T_co: ...
133+
@overload
134+
def mul(a: SupportsMul[_T_contra, _T_co], b: _T_contra, /) -> _T_co:
117135
"""Same as a * b."""
118136

119-
def matmul(a: Any, b: Any, /) -> Any:
137+
@overload
138+
def mul(a: _T_contra, b: SupportsRMul[_T_contra, _T_co], /) -> _T_co: ...
139+
def matmul(a, b, /):
120140
"""Same as a @ b."""
121141

122142
def neg(a: _SupportsNeg[_T_co], /) -> _T_co:
123143
"""Same as -a."""
124144

125-
def or_(a: Any, b: Any, /) -> Any:
145+
def or_(a, b, /):
126146
"""Same as a | b."""
127147

128148
def pos(a: _SupportsPos[_T_co], /) -> _T_co:
129149
"""Same as +a."""
130150

131-
def pow(a: Any, b: Any, /) -> Any:
151+
def pow(a, b, /):
132152
"""Same as a ** b."""
133153

134-
def rshift(a: Any, b: Any, /) -> Any:
154+
def rshift(a, b, /):
135155
"""Same as a >> b."""
136156

137-
def sub(a: Any, b: Any, /) -> Any:
157+
@overload
158+
def sub(a: SupportsSub[_T_contra, _T_co], b: _T_contra, /) -> _T_co:
138159
"""Same as a - b."""
139160

140-
def truediv(a: Any, b: Any, /) -> Any:
161+
@overload
162+
def sub(a: _T_contra, b: SupportsRSub[_T_contra, _T_co], /) -> _T_co: ...
163+
def truediv(a, b, /):
141164
"""Same as a / b."""
142165

143-
def xor(a: Any, b: Any, /) -> Any:
166+
def xor(a, b, /):
144167
"""Same as a ^ b."""
145168

146169
def concat(a: Sequence[_T], b: Sequence[_T], /) -> Sequence[_T]:
@@ -187,46 +210,46 @@ def length_hint(obj: object, default: int = 0, /) -> int:
187210
The result will be an integer >= 0.
188211
"""
189212

190-
def iadd(a: Any, b: Any, /) -> Any:
213+
def iadd(a, b, /):
191214
"""Same as a += b."""
192215

193-
def iand(a: Any, b: Any, /) -> Any:
216+
def iand(a, b, /):
194217
"""Same as a &= b."""
195218

196-
def iconcat(a: Any, b: Any, /) -> Any:
219+
def iconcat(a, b, /):
197220
"""Same as a += b, for a and b sequences."""
198221

199-
def ifloordiv(a: Any, b: Any, /) -> Any:
222+
def ifloordiv(a, b, /):
200223
"""Same as a //= b."""
201224

202-
def ilshift(a: Any, b: Any, /) -> Any:
225+
def ilshift(a, b, /):
203226
"""Same as a <<= b."""
204227

205-
def imod(a: Any, b: Any, /) -> Any:
228+
def imod(a, b, /):
206229
"""Same as a %= b."""
207230

208-
def imul(a: Any, b: Any, /) -> Any:
231+
def imul(a, b, /):
209232
"""Same as a *= b."""
210233

211-
def imatmul(a: Any, b: Any, /) -> Any:
234+
def imatmul(a, b, /):
212235
"""Same as a @= b."""
213236

214-
def ior(a: Any, b: Any, /) -> Any:
237+
def ior(a, b, /):
215238
"""Same as a |= b."""
216239

217-
def ipow(a: Any, b: Any, /) -> Any:
240+
def ipow(a, b, /):
218241
"""Same as a **= b."""
219242

220-
def irshift(a: Any, b: Any, /) -> Any:
243+
def irshift(a, b, /):
221244
"""Same as a >>= b."""
222245

223-
def isub(a: Any, b: Any, /) -> Any:
246+
def isub(a, b, /):
224247
"""Same as a -= b."""
225248

226-
def itruediv(a: Any, b: Any, /) -> Any:
249+
def itruediv(a, b, /):
227250
"""Same as a /= b."""
228251

229-
def ixor(a: Any, b: Any, /) -> Any:
252+
def ixor(a, b, /):
230253
"""Same as a ^= b."""
231254

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

crates/ty_vendored/vendor/typeshed/stdlib/_socket.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ class socket:
770770
recv(buflen[, flags]) -- receive data
771771
recv_into(buffer[, nbytes[, flags]]) -- receive data (into a buffer)
772772
recvfrom(buflen[, flags]) -- receive data and sender's address
773-
recvfrom_into(buffer[, nbytes, [, flags])
773+
recvfrom_into(buffer[, nbytes, [, flags]])
774774
-- receive data and sender's address (into a buffer)
775775
sendall(data[, flags]) -- send all data
776776
send(data[, flags]) -- send data, may not send all of it
@@ -797,7 +797,7 @@ class socket:
797797
"""the socket protocol"""
798798
# F811: "Redefinition of unused `timeout`"
799799
@property
800-
def timeout(self) -> float | None: # noqa: F811
800+
def timeout(self) -> float | None:
801801
"""the socket timeout"""
802802
if sys.platform == "win32":
803803
def __init__(
@@ -1236,7 +1236,7 @@ def getdefaulttimeout() -> float | None:
12361236
"""
12371237

12381238
# F811: "Redefinition of unused `timeout`"
1239-
def setdefaulttimeout(timeout: float | None, /) -> None: # noqa: F811
1239+
def setdefaulttimeout(timeout: float | None, /) -> None:
12401240
"""setdefaulttimeout(timeout)
12411241
12421242
Set the default timeout in seconds (float) for new socket objects.

crates/ty_vendored/vendor/typeshed/stdlib/_sqlite3.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ if sys.version_info >= (3, 11):
171171
SQLITE_IOERR_VNODE: Final = 6922
172172
SQLITE_IOERR_WRITE: Final = 778
173173
SQLITE_LIMIT_ATTACHED: Final = 7
174-
SQLITE_LIMIT_COLUMN: Final = 22
174+
SQLITE_LIMIT_COLUMN: Final = 2
175175
SQLITE_LIMIT_COMPOUND_SELECT: Final = 4
176176
SQLITE_LIMIT_EXPR_DEPTH: Final = 3
177177
SQLITE_LIMIT_FUNCTION_ARG: Final = 6

crates/ty_vendored/vendor/typeshed/stdlib/_ssl.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ CERT_REQUIRED: Final = 2
293293

294294
# verify flags
295295
VERIFY_DEFAULT: Final = 0
296-
VERIFY_CRL_CHECK_LEAF: Final = 0x4
297-
VERIFY_CRL_CHECK_CHAIN: Final = 0x8
296+
VERIFY_CRL_CHECK_LEAF: Final = 0x04
297+
VERIFY_CRL_CHECK_CHAIN: Final = 0x0C
298298
VERIFY_X509_STRICT: Final = 0x20
299299
VERIFY_X509_TRUSTED_FIRST: Final = 0x8000
300300
if sys.version_info >= (3, 10):
@@ -340,7 +340,7 @@ PROTOCOL_TLSv1_1: Final = 4
340340
PROTOCOL_TLSv1_2: Final = 5
341341

342342
# protocol options
343-
OP_ALL: Final = 0x80000050
343+
OP_ALL: Final[int]
344344
OP_NO_SSLv2: Final = 0x0
345345
OP_NO_SSLv3: Final = 0x2000000
346346
OP_NO_TLSv1: Final = 0x4000000

crates/ty_vendored/vendor/typeshed/stdlib/_typeshed/__init__.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ class SupportsMul(Protocol[_T_contra, _T_co]):
126126
class SupportsRMul(Protocol[_T_contra, _T_co]):
127127
def __rmul__(self, x: _T_contra, /) -> _T_co: ...
128128

129+
class SupportsMod(Protocol[_T_contra, _T_co]):
130+
def __mod__(self, other: _T_contra, /) -> _T_co: ...
131+
132+
class SupportsRMod(Protocol[_T_contra, _T_co]):
133+
def __rmod__(self, other: _T_contra, /) -> _T_co: ...
134+
129135
class SupportsDivMod(Protocol[_T_contra, _T_co]):
130136
def __divmod__(self, other: _T_contra, /) -> _T_co: ...
131137

crates/ty_vendored/vendor/typeshed/stdlib/annotationlib.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ if sys.version_info >= (3, 14):
184184
does not exist, the __annotate__ function is called. The
185185
FORWARDREF format uses __annotations__ if it exists and can be
186186
evaluated, and otherwise falls back to calling the __annotate__ function.
187-
The SOURCE format tries __annotate__ first, and falls back to
187+
The STRING format tries __annotate__ first, and falls back to
188188
using __annotations__, stringified using annotations_to_string().
189189
190190
This function handles several details for you:

crates/ty_vendored/vendor/typeshed/stdlib/argparse.pyi

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class _ActionsContainer:
160160
const: Any = ...,
161161
default: Any = ...,
162162
type: _ActionType = ...,
163-
choices: Iterable[_T] | None = ...,
163+
choices: Iterable[Any] | None = ..., # choices must match the type specified
164164
required: bool = ...,
165165
help: str | None = ...,
166166
metavar: str | tuple[str, ...] | None = ...,
@@ -273,7 +273,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
273273
usage: str | None = None,
274274
description: str | None = None,
275275
epilog: str | None = None,
276-
parents: Sequence[ArgumentParser] = [],
276+
parents: Iterable[ArgumentParser] = [],
277277
formatter_class: _FormatterClass = ...,
278278
prefix_chars: str = "-",
279279
fromfile_prefix_chars: str | None = None,
@@ -293,7 +293,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
293293
usage: str | None = None,
294294
description: str | None = None,
295295
epilog: str | None = None,
296-
parents: Sequence[ArgumentParser] = [],
296+
parents: Iterable[ArgumentParser] = [],
297297
formatter_class: _FormatterClass = ...,
298298
prefix_chars: str = "-",
299299
fromfile_prefix_chars: str | None = None,
@@ -305,9 +305,9 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
305305
) -> None: ...
306306

307307
@overload
308-
def parse_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ...
308+
def parse_args(self, args: Iterable[str] | None = None, namespace: None = None) -> Namespace: ...
309309
@overload
310-
def parse_args(self, args: Sequence[str] | None, namespace: _N) -> _N: ...
310+
def parse_args(self, args: Iterable[str] | None, namespace: _N) -> _N: ...
311311
@overload
312312
def parse_args(self, *, namespace: _N) -> _N: ...
313313
@overload
@@ -344,9 +344,9 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
344344
def format_usage(self) -> str: ...
345345
def format_help(self) -> str: ...
346346
@overload
347-
def parse_known_args(self, args: Sequence[str] | None = None, namespace: None = None) -> tuple[Namespace, list[str]]: ...
347+
def parse_known_args(self, args: Iterable[str] | None = None, namespace: None = None) -> tuple[Namespace, list[str]]: ...
348348
@overload
349-
def parse_known_args(self, args: Sequence[str] | None, namespace: _N) -> tuple[_N, list[str]]: ...
349+
def parse_known_args(self, args: Iterable[str] | None, namespace: _N) -> tuple[_N, list[str]]: ...
350350
@overload
351351
def parse_known_args(self, *, namespace: _N) -> tuple[_N, list[str]]: ...
352352
def convert_arg_line_to_args(self, arg_line: str) -> list[str]: ...
@@ -362,17 +362,17 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
362362
"""
363363

364364
@overload
365-
def parse_intermixed_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ...
365+
def parse_intermixed_args(self, args: Iterable[str] | None = None, namespace: None = None) -> Namespace: ...
366366
@overload
367-
def parse_intermixed_args(self, args: Sequence[str] | None, namespace: _N) -> _N: ...
367+
def parse_intermixed_args(self, args: Iterable[str] | None, namespace: _N) -> _N: ...
368368
@overload
369369
def parse_intermixed_args(self, *, namespace: _N) -> _N: ...
370370
@overload
371371
def parse_known_intermixed_args(
372-
self, args: Sequence[str] | None = None, namespace: None = None
372+
self, args: Iterable[str] | None = None, namespace: None = None
373373
) -> tuple[Namespace, list[str]]: ...
374374
@overload
375-
def parse_known_intermixed_args(self, args: Sequence[str] | None, namespace: _N) -> tuple[_N, list[str]]: ...
375+
def parse_known_intermixed_args(self, args: Iterable[str] | None, namespace: _N) -> tuple[_N, list[str]]: ...
376376
@overload
377377
def parse_known_intermixed_args(self, *, namespace: _N) -> tuple[_N, list[str]]: ...
378378
# undocumented
@@ -464,7 +464,7 @@ class HelpFormatter:
464464
def _metavar_formatter(self, action: Action, default_metavar: str) -> Callable[[int], tuple[str, ...]]: ...
465465
def _format_args(self, action: Action, default_metavar: str) -> str: ...
466466
def _expand_help(self, action: Action) -> str: ...
467-
def _iter_indented_subactions(self, action: Action) -> Generator[Action, None, None]: ...
467+
def _iter_indented_subactions(self, action: Action) -> Generator[Action]: ...
468468
def _split_lines(self, text: str, width: int) -> list[str]: ...
469469
def _fill_text(self, text: str, width: int, indent: str) -> str: ...
470470
def _get_help_string(self, action: Action) -> str | None: ...
@@ -1015,13 +1015,13 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
10151015
*,
10161016
deprecated: bool = False,
10171017
help: str | None = ...,
1018-
aliases: Sequence[str] = ...,
1018+
aliases: Iterable[str] = ...,
10191019
# Kwargs from ArgumentParser constructor
10201020
prog: str | None = ...,
10211021
usage: str | None = ...,
10221022
description: str | None = ...,
10231023
epilog: str | None = ...,
1024-
parents: Sequence[_ArgumentParserT] = ...,
1024+
parents: Iterable[_ArgumentParserT] = ...,
10251025
formatter_class: _FormatterClass = ...,
10261026
prefix_chars: str = ...,
10271027
fromfile_prefix_chars: str | None = ...,
@@ -1041,13 +1041,13 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
10411041
*,
10421042
deprecated: bool = False,
10431043
help: str | None = ...,
1044-
aliases: Sequence[str] = ...,
1044+
aliases: Iterable[str] = ...,
10451045
# Kwargs from ArgumentParser constructor
10461046
prog: str | None = ...,
10471047
usage: str | None = ...,
10481048
description: str | None = ...,
10491049
epilog: str | None = ...,
1050-
parents: Sequence[_ArgumentParserT] = ...,
1050+
parents: Iterable[_ArgumentParserT] = ...,
10511051
formatter_class: _FormatterClass = ...,
10521052
prefix_chars: str = ...,
10531053
fromfile_prefix_chars: str | None = ...,
@@ -1064,13 +1064,13 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
10641064
name: str,
10651065
*,
10661066
help: str | None = ...,
1067-
aliases: Sequence[str] = ...,
1067+
aliases: Iterable[str] = ...,
10681068
# Kwargs from ArgumentParser constructor
10691069
prog: str | None = ...,
10701070
usage: str | None = ...,
10711071
description: str | None = ...,
10721072
epilog: str | None = ...,
1073-
parents: Sequence[_ArgumentParserT] = ...,
1073+
parents: Iterable[_ArgumentParserT] = ...,
10741074
formatter_class: _FormatterClass = ...,
10751075
prefix_chars: str = ...,
10761076
fromfile_prefix_chars: str | None = ...,

crates/ty_vendored/vendor/typeshed/stdlib/asyncio/queues.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Queue(Generic[_T], _LoopBoundMixin): # noqa: Y059
3737
is an integer greater than 0, then "await put()" will block when the
3838
queue reaches maxsize, until an item is removed by get().
3939
40-
Unlike the standard library Queue, you can reliably know this Queue's size
40+
Unlike queue.Queue, you can reliably know this Queue's size
4141
with qsize(), since your single-threaded asyncio application won't be
4242
interrupted between calling qsize() and doing an operation on the Queue.
4343
"""

0 commit comments

Comments
 (0)