Skip to content

Commit fb70de6

Browse files
[ty] Sync vendored typeshed stubs (#23642)
Close and reopen this PR to trigger CI --------- Co-authored-by: typeshedbot <>
1 parent 329b713 commit fb70de6

12 files changed

Lines changed: 156 additions & 96 deletions

File tree

crates/ty_vendored/vendor/typeshed/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ you can install the type stubs using
3838
$ pip install types-html5lib types-requests
3939
```
4040

41-
These PyPI packages follow [PEP 561](http://www.python.org/dev/peps/pep-0561/)
41+
These PyPI packages follow [the typing spec standards](https://typing.python.org/en/latest/spec/distributing.html)
4242
and are automatically released (up to once a day) by
4343
[typeshed internal machinery](https://github.com/typeshed-internal/stub_uploader).
4444

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1b3cec156330a93f6bb22b6636bca38c27f8f721
1+
843c1fd5a148da85e523c1b4ee680226f89986aa

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

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ from collections.abc import Callable
99
from threading import Thread
1010
from types import TracebackType
1111
from typing import Any, Final, NoReturn, final, overload
12-
from typing_extensions import TypeVarTuple, Unpack, disjoint_base
12+
from typing_extensions import TypeVarTuple, Unpack, deprecated, disjoint_base
1313

1414
_Ts = TypeVarTuple("_Ts")
1515

@@ -119,13 +119,16 @@ if sys.version_info >= (3, 13):
119119
def locked(self) -> bool:
120120
"""Return whether the lock is in the locked state."""
121121

122-
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool:
122+
@deprecated("Obsolete synonym. Use `acquire()` instead.")
123+
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: # undocumented
123124
"""An obsolete synonym of acquire()."""
124125

125-
def release_lock(self) -> None:
126+
@deprecated("Obsolete synonym. Use `release()` instead.")
127+
def release_lock(self) -> None: # undocumented
126128
"""An obsolete synonym of release()."""
127129

128-
def locked_lock(self) -> bool:
130+
@deprecated("Obsolete synonym. Use `locked()` instead.")
131+
def locked_lock(self) -> bool: # undocumented
129132
"""An obsolete synonym of locked()."""
130133

131134
def __enter__(self) -> bool:
@@ -180,7 +183,8 @@ else:
180183
Return whether the lock is in the locked state.
181184
"""
182185

183-
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool:
186+
@deprecated("Obsolete synonym. Use `acquire()` instead.")
187+
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: # undocumented
184188
"""acquire(blocking=True, timeout=-1) -> bool
185189
(acquire_lock() is an obsolete synonym)
186190
@@ -192,7 +196,8 @@ else:
192196
The blocking operation is interruptible.
193197
"""
194198

195-
def release_lock(self) -> None:
199+
@deprecated("Obsolete synonym. Use `release()` instead.")
200+
def release_lock(self) -> None: # undocumented
196201
"""release()
197202
(release_lock() is an obsolete synonym)
198203
@@ -201,7 +206,8 @@ else:
201206
but it needn't be locked by the same thread that unlocks it.
202207
"""
203208

204-
def locked_lock(self) -> bool:
209+
@deprecated("Obsolete synonym. Use `locked()` instead.")
210+
def locked_lock(self) -> bool: # undocumented
205211
"""locked() -> bool
206212
(locked_lock() is an obsolete synonym)
207213
@@ -245,14 +251,14 @@ def start_new_thread(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpa
245251

246252
@overload
247253
def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ...
248-
249-
# Obsolete synonym for start_new_thread()
250254
@overload
251-
def start_new(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int:
255+
@deprecated("Obsolete synonym. Use `start_new_thread()` instead.")
256+
def start_new(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int: # undocumented
252257
"""An obsolete synonym of start_new_thread()."""
253258

254259
@overload
255-
def start_new(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ...
260+
@deprecated("Obsolete synonym. Use `start_new_thread()` instead.")
261+
def start_new(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ... # undocumented
256262

257263
if sys.version_info >= (3, 10):
258264
def interrupt_main(signum: signal.Signals = signal.SIGINT, /) -> None:
@@ -277,15 +283,17 @@ def exit() -> NoReturn:
277283
thread to exit silently unless the exception is caught.
278284
"""
279285

280-
def exit_thread() -> NoReturn: # Obsolete synonym for exit()
286+
@deprecated("Obsolete synonym. Use `exit()` instead.")
287+
def exit_thread() -> NoReturn: # undocumented
281288
"""An obsolete synonym of exit()."""
282289

283290
def allocate_lock() -> LockType:
284291
"""Create a new lock object. See help(type(threading.Lock())) for
285292
information about locks.
286293
"""
287294

288-
def allocate() -> LockType: # Obsolete synonym for allocate_lock()
295+
@deprecated("Obsolete synonym. Use `allocate_lock()` instead.")
296+
def allocate() -> LockType: # undocumented
289297
"""An obsolete synonym of allocate_lock()."""
290298

291299
def get_ident() -> int:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ class ABCMeta(type):
3737
mcls: type[_typeshed.Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any], **kwargs: Any
3838
) -> _typeshed.Self: ...
3939

40-
def __instancecheck__(cls: ABCMeta, instance: Any) -> bool:
40+
def __instancecheck__(cls: ABCMeta, instance: Any, /) -> bool:
4141
"""Override for isinstance(instance, cls)."""
4242

43-
def __subclasscheck__(cls: ABCMeta, subclass: type) -> bool:
43+
def __subclasscheck__(cls: ABCMeta, subclass: type, /) -> bool:
4444
"""Override for issubclass(subclass, cls)."""
4545

4646
def _dump_registry(cls: ABCMeta, file: SupportsWrite[str] | None = None) -> None:

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ else:
609609
"""
610610

611611
if sys.version_info >= (3, 11):
612-
@overload
613612
async def wait(
614613
fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
615614
) -> tuple[set[_FT], set[_FT]]:
@@ -627,11 +626,6 @@ if sys.version_info >= (3, 11):
627626
when the timeout occurs are returned in the second set.
628627
"""
629628

630-
@overload
631-
async def wait(
632-
fs: Iterable[Task[_T]], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
633-
) -> tuple[set[Task[_T]], set[Task[_T]]]: ...
634-
635629
elif sys.version_info >= (3, 10):
636630
@overload
637631
async def wait( # type: ignore[overload-overlap]

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

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,19 +1304,15 @@ def makeLogRecord(dict: Mapping[str, object]) -> LogRecord:
13041304
instance.
13051305
"""
13061306

1307+
@overload # handlers is non-None
13071308
def basicConfig(
13081309
*,
1309-
filename: StrPath | None = ...,
1310-
filemode: str = ...,
1311-
format: str = ...,
1312-
datefmt: str | None = ...,
1313-
style: _FormatStyle = ...,
1314-
level: _Level | None = ...,
1315-
stream: SupportsWrite[str] | None = ...,
1316-
handlers: Iterable[Handler] | None = ...,
1317-
force: bool | None = ...,
1318-
encoding: str | None = ...,
1319-
errors: str | None = ...,
1310+
format: str = ..., # default value depends on the value of `style`
1311+
datefmt: str | None = None,
1312+
style: _FormatStyle = "%",
1313+
level: _Level | None = None,
1314+
handlers: Iterable[Handler],
1315+
force: bool | None = False,
13201316
) -> None:
13211317
"""
13221318
Do basic configuration for the logging system.
@@ -1386,6 +1382,31 @@ def basicConfig(
13861382
Added the ``encoding`` and ``errors`` parameters.
13871383
"""
13881384

1385+
@overload # handlers is None, filename is passed (but possibly None)
1386+
def basicConfig(
1387+
*,
1388+
filename: StrPath | None,
1389+
filemode: str = "a",
1390+
format: str = ..., # default value depends on the value of `style`
1391+
datefmt: str | None = None,
1392+
style: _FormatStyle = "%",
1393+
level: _Level | None = None,
1394+
handlers: None = None,
1395+
force: bool | None = False,
1396+
encoding: str | None = None,
1397+
errors: str | None = "backslashreplace",
1398+
) -> None: ...
1399+
@overload # handlers is None, filename is not passed
1400+
def basicConfig(
1401+
*,
1402+
format: str = ..., # default value depends on the value of `style`
1403+
datefmt: str | None = None,
1404+
style: _FormatStyle = "%",
1405+
level: _Level | None = None,
1406+
stream: SupportsWrite[str] | None = None,
1407+
handlers: None = None,
1408+
force: bool | None = False,
1409+
) -> None: ...
13891410
def shutdown(handlerList: Sequence[Any] = ...) -> None: # handlerList is undocumented
13901411
"""
13911412
Perform any cleanup actions in the logging system (e.g. flushing

crates/ty_vendored/vendor/typeshed/stdlib/multiprocessing/managers.pyi

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ from .util import Finalize as _Finalize
2626
__all__ = ["BaseManager", "SyncManager", "BaseProxy", "Token", "SharedMemoryManager"]
2727

2828
_T = TypeVar("_T")
29+
_T1 = TypeVar("_T1")
30+
_T2 = TypeVar("_T2")
2931
_KT = TypeVar("_KT")
3032
_VT = TypeVar("_VT")
3133
_S = TypeVar("_S")
@@ -114,6 +116,25 @@ if sys.version_info >= (3, 13):
114116
def keys(self) -> list[_KT]: ... # type: ignore[override]
115117
def items(self) -> list[tuple[_KT, _VT]]: ... # type: ignore[override]
116118
def values(self) -> list[_VT]: ... # type: ignore[override]
119+
if sys.version_info >= (3, 14):
120+
# Next methods are copied from builtins.dict
121+
@overload
122+
def fromkeys(self, iterable: Iterable[_T], value: None = None, /) -> dict[_T, Any | None]: ...
123+
@overload
124+
def fromkeys(self, iterable: Iterable[_T], value: _S, /) -> dict[_T, _S]: ...
125+
def __reversed__(self) -> Iterator[_KT]: ...
126+
@overload
127+
def __or__(self, value: dict[_KT, _VT], /) -> dict[_KT, _VT]: ...
128+
@overload
129+
def __or__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ...
130+
@overload
131+
def __ror__(self, value: dict[_KT, _VT], /) -> dict[_KT, _VT]: ...
132+
@overload
133+
def __ror__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ...
134+
@overload # type: ignore[misc]
135+
def __ior__(self, value: SupportsKeysAndGetItem[_KT, _VT], /) -> Self: ...
136+
@overload
137+
def __ior__(self, value: Iterable[tuple[_KT, _VT]], /) -> Self: ...
117138

118139
class DictProxy(_BaseDictProxy[_KT, _VT]):
119140
def __class_getitem__(cls, args: Any, /) -> GenericAlias:
@@ -217,6 +238,8 @@ class BaseListProxy(BaseProxy, MutableSequence[_T]):
217238
def insert(self, index: SupportsIndex, object: _T, /) -> None: ...
218239
def remove(self, value: _T, /) -> None: ...
219240
if sys.version_info >= (3, 14):
241+
# Next methods are copied from builtins.list
242+
def clear(self) -> None: ...
220243
def copy(self) -> list[_T]: ...
221244
# Use BaseListProxy[SupportsRichComparisonT] for the first overload rather than [SupportsRichComparison]
222245
# to work around invariance

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
import sys
22
from types import GenericAlias
3-
from typing import Any, Generic, TypeVar
3+
from typing import Any, Generic, NewType, TypeVar
44

55
__all__ = ["Queue", "SimpleQueue", "JoinableQueue"]
66

77
_T = TypeVar("_T")
88

9+
_QueueState = NewType("_QueueState", object)
10+
_JoinableQueueState = NewType("_JoinableQueueState", object)
11+
_SimpleQueueState = NewType("_SimpleQueueState", object)
12+
913
class Queue(Generic[_T]):
1014
# FIXME: `ctx` is a circular dependency and it's not actually optional.
1115
# It's marked as such to be able to use the generic Queue in __init__.pyi.
1216
def __init__(self, maxsize: int = 0, *, ctx: Any = ...) -> None: ...
17+
def __getstate__(self) -> _QueueState: ...
18+
def __setstate__(self, state: _QueueState) -> None: ...
1319
def put(self, obj: _T, block: bool = True, timeout: float | None = None) -> None: ...
1420
def get(self, block: bool = True, timeout: float | None = None) -> _T: ...
1521
def qsize(self) -> int: ...
@@ -28,13 +34,17 @@ class Queue(Generic[_T]):
2834
"""
2935

3036
class JoinableQueue(Queue[_T]):
37+
def __getstate__(self) -> _JoinableQueueState: ... # type: ignore[override]
38+
def __setstate__(self, state: _JoinableQueueState) -> None: ... # type: ignore[override]
3139
def task_done(self) -> None: ...
3240
def join(self) -> None: ...
3341

3442
class SimpleQueue(Generic[_T]):
3543
def __init__(self, *, ctx: Any = ...) -> None: ...
3644
def close(self) -> None: ...
3745
def empty(self) -> bool: ...
46+
def __getstate__(self) -> _SimpleQueueState: ...
47+
def __setstate__(self, state: _SimpleQueueState) -> None: ...
3848
def get(self) -> _T: ...
3949
def put(self, obj: _T) -> None: ...
4050
def __class_getitem__(cls, item: Any, /) -> GenericAlias:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ if sys.version_info >= (3, 13):
4646
opname: Final[list[str]]
4747

4848
opmap: Final[dict[str, int]]
49-
HAVE_ARGUMENT: Final = 43
50-
EXTENDED_ARG: Final = 69
49+
HAVE_ARGUMENT: Final[int]
50+
EXTENDED_ARG: Final[int]
5151

5252
def stack_effect(opcode: int, oparg: int | None = None, /, *, jump: bool | None = None) -> int:
5353
"""Compute the stack effect of the opcode."""

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Misc variables:
2323
2424
"""
2525

26+
import sys
2627
from _pickle import (
2728
PickleError as PickleError,
2829
Pickler as Pickler,
@@ -128,7 +129,10 @@ __all__ = [
128129
]
129130

130131
HIGHEST_PROTOCOL: Final = 5
131-
DEFAULT_PROTOCOL: Final = 5
132+
if sys.version_info >= (3, 14):
133+
DEFAULT_PROTOCOL: Final = 5
134+
else:
135+
DEFAULT_PROTOCOL: Final = 4
132136

133137
bytes_types: tuple[type[Any], ...] # undocumented
134138

0 commit comments

Comments
 (0)