Skip to content

Commit 0d615b8

Browse files
Sync vendored typeshed stubs (#16448)
Close and reopen this PR to trigger CI Co-authored-by: typeshedbot <>
1 parent 4431978 commit 0d615b8

30 files changed

+1225
-858
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cc8ca939c0477a49fcce0554fa1743bd5c656a11
1+
0b13c1deb6d0b2cdc78b246da9a0863c87dd8424

crates/red_knot_vendored/vendor/typeshed/stdlib/_frozen_importlib_external.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ else:
2626

2727
MAGIC_NUMBER: bytes
2828

29-
def cache_from_source(path: str, debug_override: bool | None = None, *, optimization: Any | None = None) -> str: ...
30-
def source_from_cache(path: str) -> str: ...
29+
def cache_from_source(path: StrPath, debug_override: bool | None = None, *, optimization: Any | None = None) -> str: ...
30+
def source_from_cache(path: StrPath) -> str: ...
3131
def decode_source(source_bytes: ReadableBuffer) -> str: ...
3232
def spec_from_file_location(
3333
name: str,

crates/red_knot_vendored/vendor/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: ...

crates/red_knot_vendored/vendor/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

crates/red_knot_vendored/vendor/typeshed/stdlib/builtins.pyi

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ from _typeshed import (
1010
ConvertibleToFloat,
1111
ConvertibleToInt,
1212
FileDescriptorOrPath,
13-
MaybeNone,
1413
OpenBinaryMode,
1514
OpenBinaryModeReading,
1615
OpenBinaryModeUpdating,
@@ -95,9 +94,14 @@ _SupportsAnextT = TypeVar("_SupportsAnextT", bound=SupportsAnext[Any], covariant
9594
_AwaitableT = TypeVar("_AwaitableT", bound=Awaitable[Any])
9695
_AwaitableT_co = TypeVar("_AwaitableT_co", bound=Awaitable[Any], covariant=True)
9796
_P = ParamSpec("_P")
98-
_StartT = TypeVar("_StartT", covariant=True, default=Any)
99-
_StopT = TypeVar("_StopT", covariant=True, default=Any)
100-
_StepT = TypeVar("_StepT", covariant=True, default=Any)
97+
98+
# Type variables for slice
99+
_StartT_co = TypeVar("_StartT_co", covariant=True, default=Any) # slice -> slice[Any, Any, Any]
100+
_StopT_co = TypeVar("_StopT_co", covariant=True, default=_StartT_co) # slice[A] -> slice[A, A, A]
101+
# NOTE: step could differ from start and stop, (e.g. datetime/timedelta)l
102+
# the default (start|stop) is chosen to cater to the most common case of int/index slices.
103+
# FIXME: https://github.com/python/typing/issues/213 (replace step=start|stop with step=start&stop)
104+
_StepT_co = TypeVar("_StepT_co", covariant=True, default=_StartT_co | _StopT_co) # slice[A,B] -> slice[A, B, A|B]
101105

102106
class object:
103107
__doc__: str | None
@@ -940,23 +944,35 @@ class bool(int):
940944
def __invert__(self) -> int: ...
941945

942946
@final
943-
class slice(Generic[_StartT, _StopT, _StepT]):
947+
class slice(Generic[_StartT_co, _StopT_co, _StepT_co]):
944948
@property
945-
def start(self) -> _StartT: ...
949+
def start(self) -> _StartT_co: ...
946950
@property
947-
def step(self) -> _StepT: ...
951+
def step(self) -> _StepT_co: ...
948952
@property
949-
def stop(self) -> _StopT: ...
950-
@overload
951-
def __new__(cls, stop: int | None, /) -> slice[int | MaybeNone, int | MaybeNone, int | MaybeNone]: ...
953+
def stop(self) -> _StopT_co: ...
954+
# Note: __new__ overloads map `None` to `Any`, since users expect slice(x, None)
955+
# to be compatible with slice(None, x).
956+
# generic slice --------------------------------------------------------------------
952957
@overload
953-
def __new__(
954-
cls, start: int | None, stop: int | None, step: int | None = None, /
955-
) -> slice[int | MaybeNone, int | MaybeNone, int | MaybeNone]: ...
958+
def __new__(cls, start: None, stop: None = None, step: None = None, /) -> slice[Any, Any, Any]: ...
959+
# unary overloads ------------------------------------------------------------------
956960
@overload
957961
def __new__(cls, stop: _T2, /) -> slice[Any, _T2, Any]: ...
962+
# binary overloads -----------------------------------------------------------------
963+
@overload
964+
def __new__(cls, start: _T1, stop: None, step: None = None, /) -> slice[_T1, Any, Any]: ...
965+
@overload
966+
def __new__(cls, start: None, stop: _T2, step: None = None, /) -> slice[Any, _T2, Any]: ...
967+
@overload
968+
def __new__(cls, start: _T1, stop: _T2, step: None = None, /) -> slice[_T1, _T2, Any]: ...
969+
# ternary overloads ----------------------------------------------------------------
970+
@overload
971+
def __new__(cls, start: None, stop: None, step: _T3, /) -> slice[Any, Any, _T3]: ...
972+
@overload
973+
def __new__(cls, start: _T1, stop: None, step: _T3, /) -> slice[_T1, Any, _T3]: ...
958974
@overload
959-
def __new__(cls, start: _T1, stop: _T2, /) -> slice[_T1, _T2, Any]: ...
975+
def __new__(cls, start: None, stop: _T2, step: _T3, /) -> slice[Any, _T2, _T3]: ...
960976
@overload
961977
def __new__(cls, start: _T1, stop: _T2, step: _T3, /) -> slice[_T1, _T2, _T3]: ...
962978
def __eq__(self, value: object, /) -> bool: ...

crates/red_knot_vendored/vendor/typeshed/stdlib/codecs.pyi

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ from _codecs import *
33
from _typeshed import ReadableBuffer
44
from abc import abstractmethod
55
from collections.abc import Callable, Generator, Iterable
6-
from typing import Any, BinaryIO, ClassVar, Final, Literal, Protocol, TextIO
7-
from typing_extensions import Self
6+
from typing import Any, BinaryIO, ClassVar, Final, Literal, Protocol, TextIO, overload
7+
from typing_extensions import Self, TypeAlias
88

99
__all__ = [
1010
"register",
@@ -58,6 +58,21 @@ BOM32_LE: Final = b"\xff\xfe"
5858
BOM64_BE: Final = b"\x00\x00\xfe\xff"
5959
BOM64_LE: Final = b"\xff\xfe\x00\x00"
6060

61+
_BufferedEncoding: TypeAlias = Literal[
62+
"idna",
63+
"raw-unicode-escape",
64+
"unicode-escape",
65+
"utf-16",
66+
"utf-16-be",
67+
"utf-16-le",
68+
"utf-32",
69+
"utf-32-be",
70+
"utf-32-le",
71+
"utf-7",
72+
"utf-8",
73+
"utf-8-sig",
74+
]
75+
6176
class _WritableStream(Protocol):
6277
def write(self, data: bytes, /) -> object: ...
6378
def seek(self, offset: int, whence: int, /) -> object: ...
@@ -94,6 +109,9 @@ class _IncrementalEncoder(Protocol):
94109
class _IncrementalDecoder(Protocol):
95110
def __call__(self, errors: str = ...) -> IncrementalDecoder: ...
96111

112+
class _BufferedIncrementalDecoder(Protocol):
113+
def __call__(self, errors: str = ...) -> BufferedIncrementalDecoder: ...
114+
97115
class CodecInfo(tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):
98116
_is_text_encoding: bool
99117
@property
@@ -125,6 +143,9 @@ class CodecInfo(tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):
125143
def getencoder(encoding: str) -> _Encoder: ...
126144
def getdecoder(encoding: str) -> _Decoder: ...
127145
def getincrementalencoder(encoding: str) -> _IncrementalEncoder: ...
146+
@overload
147+
def getincrementaldecoder(encoding: _BufferedEncoding) -> _BufferedIncrementalDecoder: ...
148+
@overload
128149
def getincrementaldecoder(encoding: str) -> _IncrementalDecoder: ...
129150
def getreader(encoding: str) -> _StreamReader: ...
130151
def getwriter(encoding: str) -> _StreamWriter: ...

0 commit comments

Comments
 (0)