Skip to content

Commit 7ff3c99

Browse files
author
mypybot
committed
Sync typeshed
Source commit: python/typeshed@0b13c1d
1 parent 27417ba commit 7ff3c99

31 files changed

+1301
-875
lines changed

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
66
from typing import Any, Literal, TextIO, TypeVar
@@ -13,7 +13,7 @@ _T = TypeVar("_T")
1313
_T_co = TypeVar("_T_co", covariant=True)
1414
_TaskYieldType: TypeAlias = Future[object] | None
1515

16-
class Future(Awaitable[_T], Iterable[_T]):
16+
class Future(Awaitable[_T]):
1717
_state: str
1818
@property
1919
def _exception(self) -> BaseException | None: ...

mypy/typeshed/stdlib/_ctypes.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,11 @@ class Array(_CData, Generic[_CT], metaclass=_PyCArrayType):
286286
def _type_(self) -> type[_CT]: ...
287287
@_type_.setter
288288
def _type_(self, value: type[_CT]) -> None: ...
289-
raw: bytes # Note: only available if _CT == c_char
289+
# Note: only available if _CT == c_char
290+
@property
291+
def raw(self) -> bytes: ...
292+
@raw.setter
293+
def raw(self, value: ReadableBuffer) -> None: ...
290294
value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise
291295
# TODO These methods cannot be annotated correctly at the moment.
292296
# All of these "Any"s stand for the array's element type, but it's not possible to use _CT

mypy/typeshed/stdlib/_hashlib.pyi

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@ import sys
22
from _typeshed import ReadableBuffer
33
from collections.abc import Callable
44
from types import ModuleType
5-
from typing import AnyStr, final, overload
5+
from typing import AnyStr, Protocol, final, overload, type_check_only
66
from typing_extensions import Self, TypeAlias
77

8-
_DigestMod: TypeAlias = str | Callable[[], HASH] | ModuleType | None
8+
_DigestMod: TypeAlias = str | Callable[[], _HashObject] | ModuleType | None
99

1010
openssl_md_meth_names: frozenset[str]
1111

12+
@type_check_only
13+
class _HashObject(Protocol):
14+
@property
15+
def digest_size(self) -> int: ...
16+
@property
17+
def block_size(self) -> int: ...
18+
@property
19+
def name(self) -> str: ...
20+
def copy(self) -> Self: ...
21+
def digest(self) -> bytes: ...
22+
def hexdigest(self) -> str: ...
23+
def update(self, obj: ReadableBuffer, /) -> None: ...
24+
1225
class HASH:
1326
@property
1427
def digest_size(self) -> int: ...

mypy/typeshed/stdlib/argparse.pyi

Lines changed: 3 additions & 5 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
5+
from typing import IO, Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeVar, overload
66
from typing_extensions import Self, TypeAlias, deprecated
77

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

@@ -83,7 +81,7 @@ class _ActionsContainer:
8381
# more precisely, Literal["?", "*", "+", "...", "A...", "==SUPPRESS=="],
8482
# but using this would make it hard to annotate callers that don't use a
8583
# literal argument and for subclasses to override this method.
86-
nargs: int | str | _SUPPRESS_T | None = None,
84+
nargs: int | str | None = None,
8785
const: Any = ...,
8886
default: Any = ...,
8987
type: _ActionType = ...,

mypy/typeshed/stdlib/asyncio/__init__.pyi

Lines changed: 0 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -410,93 +410,6 @@ if sys.platform == "win32":
410410
"WindowsSelectorEventLoopPolicy", # from windows_events
411411
"WindowsProactorEventLoopPolicy", # from windows_events
412412
)
413-
elif sys.version_info >= (3, 10):
414-
__all__ = (
415-
"BaseEventLoop", # from base_events
416-
"Server", # from base_events
417-
"coroutine", # from coroutines
418-
"iscoroutinefunction", # from coroutines
419-
"iscoroutine", # from coroutines
420-
"AbstractEventLoopPolicy", # from events
421-
"AbstractEventLoop", # from events
422-
"AbstractServer", # from events
423-
"Handle", # from events
424-
"TimerHandle", # from events
425-
"get_event_loop_policy", # from events
426-
"set_event_loop_policy", # from events
427-
"get_event_loop", # from events
428-
"set_event_loop", # from events
429-
"new_event_loop", # from events
430-
"get_child_watcher", # from events
431-
"set_child_watcher", # from events
432-
"_set_running_loop", # from events
433-
"get_running_loop", # from events
434-
"_get_running_loop", # from events
435-
"CancelledError", # from exceptions
436-
"InvalidStateError", # from exceptions
437-
"TimeoutError", # from exceptions
438-
"IncompleteReadError", # from exceptions
439-
"LimitOverrunError", # from exceptions
440-
"SendfileNotAvailableError", # from exceptions
441-
"Future", # from futures
442-
"wrap_future", # from futures
443-
"isfuture", # from futures
444-
"Lock", # from locks
445-
"Event", # from locks
446-
"Condition", # from locks
447-
"Semaphore", # from locks
448-
"BoundedSemaphore", # from locks
449-
"BaseProtocol", # from protocols
450-
"Protocol", # from protocols
451-
"DatagramProtocol", # from protocols
452-
"SubprocessProtocol", # from protocols
453-
"BufferedProtocol", # from protocols
454-
"run", # from runners
455-
"Queue", # from queues
456-
"PriorityQueue", # from queues
457-
"LifoQueue", # from queues
458-
"QueueFull", # from queues
459-
"QueueEmpty", # from queues
460-
"StreamReader", # from streams
461-
"StreamWriter", # from streams
462-
"StreamReaderProtocol", # from streams
463-
"open_connection", # from streams
464-
"start_server", # from streams
465-
"create_subprocess_exec", # from subprocess
466-
"create_subprocess_shell", # from subprocess
467-
"Task", # from tasks
468-
"create_task", # from tasks
469-
"FIRST_COMPLETED", # from tasks
470-
"FIRST_EXCEPTION", # from tasks
471-
"ALL_COMPLETED", # from tasks
472-
"wait", # from tasks
473-
"wait_for", # from tasks
474-
"as_completed", # from tasks
475-
"sleep", # from tasks
476-
"gather", # from tasks
477-
"shield", # from tasks
478-
"ensure_future", # from tasks
479-
"run_coroutine_threadsafe", # from tasks
480-
"current_task", # from tasks
481-
"all_tasks", # from tasks
482-
"_register_task", # from tasks
483-
"_unregister_task", # from tasks
484-
"_enter_task", # from tasks
485-
"_leave_task", # from tasks
486-
"to_thread", # from threads
487-
"BaseTransport", # from transports
488-
"ReadTransport", # from transports
489-
"WriteTransport", # from transports
490-
"Transport", # from transports
491-
"DatagramTransport", # from transports
492-
"SubprocessTransport", # from transports
493-
"SelectorEventLoop", # from windows_events
494-
"ProactorEventLoop", # from windows_events
495-
"IocpProactor", # from windows_events
496-
"DefaultEventLoopPolicy", # from windows_events
497-
"WindowsSelectorEventLoopPolicy", # from windows_events
498-
"WindowsProactorEventLoopPolicy", # from windows_events
499-
)
500413
elif sys.version_info >= (3, 9):
501414
__all__ = (
502415
"BaseEventLoop", # from base_events
@@ -1059,97 +972,6 @@ else:
1059972
"ThreadedChildWatcher", # from unix_events
1060973
"DefaultEventLoopPolicy", # from unix_events
1061974
)
1062-
elif sys.version_info >= (3, 10):
1063-
__all__ = (
1064-
"BaseEventLoop", # from base_events
1065-
"Server", # from base_events
1066-
"coroutine", # from coroutines
1067-
"iscoroutinefunction", # from coroutines
1068-
"iscoroutine", # from coroutines
1069-
"AbstractEventLoopPolicy", # from events
1070-
"AbstractEventLoop", # from events
1071-
"AbstractServer", # from events
1072-
"Handle", # from events
1073-
"TimerHandle", # from events
1074-
"get_event_loop_policy", # from events
1075-
"set_event_loop_policy", # from events
1076-
"get_event_loop", # from events
1077-
"set_event_loop", # from events
1078-
"new_event_loop", # from events
1079-
"get_child_watcher", # from events
1080-
"set_child_watcher", # from events
1081-
"_set_running_loop", # from events
1082-
"get_running_loop", # from events
1083-
"_get_running_loop", # from events
1084-
"CancelledError", # from exceptions
1085-
"InvalidStateError", # from exceptions
1086-
"TimeoutError", # from exceptions
1087-
"IncompleteReadError", # from exceptions
1088-
"LimitOverrunError", # from exceptions
1089-
"SendfileNotAvailableError", # from exceptions
1090-
"Future", # from futures
1091-
"wrap_future", # from futures
1092-
"isfuture", # from futures
1093-
"Lock", # from locks
1094-
"Event", # from locks
1095-
"Condition", # from locks
1096-
"Semaphore", # from locks
1097-
"BoundedSemaphore", # from locks
1098-
"BaseProtocol", # from protocols
1099-
"Protocol", # from protocols
1100-
"DatagramProtocol", # from protocols
1101-
"SubprocessProtocol", # from protocols
1102-
"BufferedProtocol", # from protocols
1103-
"run", # from runners
1104-
"Queue", # from queues
1105-
"PriorityQueue", # from queues
1106-
"LifoQueue", # from queues
1107-
"QueueFull", # from queues
1108-
"QueueEmpty", # from queues
1109-
"StreamReader", # from streams
1110-
"StreamWriter", # from streams
1111-
"StreamReaderProtocol", # from streams
1112-
"open_connection", # from streams
1113-
"start_server", # from streams
1114-
"open_unix_connection", # from streams
1115-
"start_unix_server", # from streams
1116-
"create_subprocess_exec", # from subprocess
1117-
"create_subprocess_shell", # from subprocess
1118-
"Task", # from tasks
1119-
"create_task", # from tasks
1120-
"FIRST_COMPLETED", # from tasks
1121-
"FIRST_EXCEPTION", # from tasks
1122-
"ALL_COMPLETED", # from tasks
1123-
"wait", # from tasks
1124-
"wait_for", # from tasks
1125-
"as_completed", # from tasks
1126-
"sleep", # from tasks
1127-
"gather", # from tasks
1128-
"shield", # from tasks
1129-
"ensure_future", # from tasks
1130-
"run_coroutine_threadsafe", # from tasks
1131-
"current_task", # from tasks
1132-
"all_tasks", # from tasks
1133-
"_register_task", # from tasks
1134-
"_unregister_task", # from tasks
1135-
"_enter_task", # from tasks
1136-
"_leave_task", # from tasks
1137-
"to_thread", # from threads
1138-
"BaseTransport", # from transports
1139-
"ReadTransport", # from transports
1140-
"WriteTransport", # from transports
1141-
"Transport", # from transports
1142-
"DatagramTransport", # from transports
1143-
"SubprocessTransport", # from transports
1144-
"SelectorEventLoop", # from unix_events
1145-
"AbstractChildWatcher", # from unix_events
1146-
"SafeChildWatcher", # from unix_events
1147-
"FastChildWatcher", # from unix_events
1148-
"PidfdChildWatcher", # from unix_events
1149-
"MultiLoopChildWatcher", # from unix_events
1150-
"ThreadedChildWatcher", # from unix_events
1151-
"DefaultEventLoopPolicy", # from unix_events
1152-
)
1153975
elif sys.version_info >= (3, 9):
1154976
__all__ = (
1155977
"BaseEventLoop", # from base_events

0 commit comments

Comments
 (0)