Skip to content

Commit e308c77

Browse files
committed
Sync typeshed
Source commit: python/typeshed@637ece0
1 parent f66e55b commit e308c77

22 files changed

Lines changed: 269 additions & 82 deletions

mypy/typeshed/stdlib/VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ py_compile: 3.0-
253253
pyclbr: 3.0-
254254
pydoc: 3.0-
255255
pydoc_data: 3.0-
256+
pydoc_data.module_docs: 3.13-
256257
pyexpat: 3.0-
257258
queue: 3.0-
258259
quopri: 3.0-

mypy/typeshed/stdlib/_asyncio.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
from asyncio.events import AbstractEventLoop
3-
from collections.abc import Awaitable, Callable, Coroutine, Generator, Iterable
3+
from collections.abc import Awaitable, Callable, Coroutine, Generator
44
from contextvars import Context
55
from types import FrameType, GenericAlias
66
from typing import Any, Literal, TextIO, TypeVar
@@ -11,7 +11,7 @@ _T_co = TypeVar("_T_co", covariant=True)
1111
_TaskYieldType: TypeAlias = Future[object] | None
1212

1313
@disjoint_base
14-
class Future(Awaitable[_T], Iterable[_T]):
14+
class Future(Awaitable[_T]):
1515
_state: str
1616
@property
1717
def _exception(self) -> BaseException | None: ...

mypy/typeshed/stdlib/_collections_abc.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from abc import abstractmethod
33
from types import MappingProxyType
4-
from typing import ( # noqa: Y022,Y038,UP035,Y057
4+
from typing import ( # noqa: Y022,Y038,UP035,Y057,RUF100
55
AbstractSet as Set,
66
AsyncGenerator as AsyncGenerator,
77
AsyncIterable as AsyncIterable,

mypy/typeshed/stdlib/_ctypes.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,11 @@ class Array(_CData, Generic[_CT], metaclass=_PyCArrayType):
320320
def _type_(self) -> type[_CT]: ...
321321
@_type_.setter
322322
def _type_(self, value: type[_CT]) -> None: ...
323-
raw: bytes # Note: only available if _CT == c_char
323+
# Note: only available if _CT == c_char
324+
@property
325+
def raw(self) -> bytes: ...
326+
@raw.setter
327+
def raw(self, value: ReadableBuffer) -> None: ...
324328
value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise
325329
# TODO: These methods cannot be annotated correctly at the moment.
326330
# All of these "Any"s stand for the array's element type, but it's not possible to use _CT

mypy/typeshed/stdlib/_thread.pyi

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

1010
_Ts = TypeVarTuple("_Ts")
1111

@@ -38,9 +38,12 @@ if sys.version_info >= (3, 13):
3838
def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ...
3939
def release(self) -> None: ...
4040
def locked(self) -> bool: ...
41-
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: ...
42-
def release_lock(self) -> None: ...
43-
def locked_lock(self) -> bool: ...
41+
@deprecated("Obsolete synonym. Use `acquire()` instead.")
42+
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: ... # undocumented
43+
@deprecated("Obsolete synonym. Use `release()` instead.")
44+
def release_lock(self) -> None: ... # undocumented
45+
@deprecated("Obsolete synonym. Use `locked()` instead.")
46+
def locked_lock(self) -> bool: ... # undocumented
4447
def __enter__(self) -> bool: ...
4548
def __exit__(
4649
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
@@ -53,9 +56,12 @@ else:
5356
def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ...
5457
def release(self) -> None: ...
5558
def locked(self) -> bool: ...
56-
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: ...
57-
def release_lock(self) -> None: ...
58-
def locked_lock(self) -> bool: ...
59+
@deprecated("Obsolete synonym. Use `acquire()` instead.")
60+
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: ... # undocumented
61+
@deprecated("Obsolete synonym. Use `release()` instead.")
62+
def release_lock(self) -> None: ... # undocumented
63+
@deprecated("Obsolete synonym. Use `locked()` instead.")
64+
def locked_lock(self) -> bool: ... # undocumented
5965
def __enter__(self) -> bool: ...
6066
def __exit__(
6167
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
@@ -65,12 +71,12 @@ else:
6571
def start_new_thread(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int: ...
6672
@overload
6773
def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ...
68-
69-
# Obsolete synonym for start_new_thread()
7074
@overload
71-
def start_new(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int: ...
75+
@deprecated("Obsolete synonym. Use `start_new_thread()` instead.")
76+
def start_new(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int: ... # undocumented
7277
@overload
73-
def start_new(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ...
78+
@deprecated("Obsolete synonym. Use `start_new_thread()` instead.")
79+
def start_new(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ... # undocumented
7480

7581
if sys.version_info >= (3, 10):
7682
def interrupt_main(signum: signal.Signals = signal.SIGINT, /) -> None: ...
@@ -79,9 +85,11 @@ else:
7985
def interrupt_main() -> None: ...
8086

8187
def exit() -> NoReturn: ...
82-
def exit_thread() -> NoReturn: ... # Obsolete synonym for exit()
88+
@deprecated("Obsolete synonym. Use `exit()` instead.")
89+
def exit_thread() -> NoReturn: ... # undocumented
8390
def allocate_lock() -> LockType: ...
84-
def allocate() -> LockType: ... # Obsolete synonym for allocate_lock()
91+
@deprecated("Obsolete synonym. Use `allocate_lock()` instead.")
92+
def allocate() -> LockType: ... # undocumented
8593
def get_ident() -> int: ...
8694
def stack_size(size: int = 0, /) -> int: ...
8795

mypy/typeshed/stdlib/argparse.pyi

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import sys
22
from _typeshed import SupportsWrite, sentinel
33
from collections.abc import Callable, Generator, Iterable, Sequence
44
from re import Pattern
5-
from typing import IO, Any, ClassVar, Final, Generic, NewType, NoReturn, Protocol, TypeVar, overload, type_check_only
5+
from typing import IO, Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeVar, overload, type_check_only
66
from typing_extensions import Self, TypeAlias, deprecated
77

88
__all__ = [
@@ -36,9 +36,7 @@ ONE_OR_MORE: Final = "+"
3636
OPTIONAL: Final = "?"
3737
PARSER: Final = "A..."
3838
REMAINDER: Final = "..."
39-
_SUPPRESS_T = NewType("_SUPPRESS_T", str)
40-
SUPPRESS: _SUPPRESS_T | str # not using Literal because argparse sometimes compares SUPPRESS with is
41-
# the | str is there so that foo = argparse.SUPPRESS; foo = "test" checks out in mypy
39+
SUPPRESS: Final = "==SUPPRESS=="
4240
ZERO_OR_MORE: Final = "*"
4341
_UNRECOGNIZED_ARGS_ATTR: Final = "_unrecognized_args" # undocumented
4442

@@ -81,7 +79,7 @@ class _ActionsContainer:
8179
# more precisely, Literal["?", "*", "+", "...", "A...", "==SUPPRESS=="],
8280
# but using this would make it hard to annotate callers that don't use a
8381
# literal argument and for subclasses to override this method.
84-
nargs: int | str | _SUPPRESS_T | None = None,
82+
nargs: int | str | None = None,
8583
const: Any = ...,
8684
default: Any = ...,
8785
type: _ActionType = ...,
@@ -336,7 +334,10 @@ class HelpFormatter:
336334
def _format_usage(
337335
self, usage: str | None, actions: Iterable[Action], groups: Iterable[_MutuallyExclusiveGroup], prefix: str | None
338336
) -> str: ...
339-
def _format_actions_usage(self, actions: Iterable[Action], groups: Iterable[_MutuallyExclusiveGroup]) -> str: ...
337+
if sys.version_info < (3, 14):
338+
# Removed in Python 3.14.3
339+
def _format_actions_usage(self, actions: Iterable[Action], groups: Iterable[_MutuallyExclusiveGroup]) -> str: ...
340+
340341
def _format_text(self, text: str) -> str: ...
341342
def _format_action(self, action: Action) -> str: ...
342343
def _format_action_invocation(self, action: Action) -> str: ...

0 commit comments

Comments
 (0)