Skip to content

Commit

Permalink
Sync vendored typeshed stubs (astral-sh#16448)
Browse files Browse the repository at this point in the history
Close and reopen this PR to trigger CI

Co-authored-by: typeshedbot <>
  • Loading branch information
github-actions[bot] authored Mar 1, 2025
1 parent 4431978 commit 0d615b8
Show file tree
Hide file tree
Showing 30 changed files with 1,225 additions and 858 deletions.
2 changes: 1 addition & 1 deletion crates/red_knot_vendored/vendor/typeshed/source_commit.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cc8ca939c0477a49fcce0554fa1743bd5c656a11
0b13c1deb6d0b2cdc78b246da9a0863c87dd8424
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ else:

MAGIC_NUMBER: bytes

def cache_from_source(path: str, debug_override: bool | None = None, *, optimization: Any | None = None) -> str: ...
def source_from_cache(path: str) -> str: ...
def cache_from_source(path: StrPath, debug_override: bool | None = None, *, optimization: Any | None = None) -> str: ...
def source_from_cache(path: StrPath) -> str: ...
def decode_source(source_bytes: ReadableBuffer) -> str: ...
def spec_from_file_location(
name: str,
Expand Down
17 changes: 15 additions & 2 deletions crates/red_knot_vendored/vendor/typeshed/stdlib/_hashlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,26 @@ import sys
from _typeshed import ReadableBuffer
from collections.abc import Callable
from types import ModuleType
from typing import AnyStr, final, overload
from typing import AnyStr, Protocol, final, overload, type_check_only
from typing_extensions import Self, TypeAlias

_DigestMod: TypeAlias = str | Callable[[], HASH] | ModuleType | None
_DigestMod: TypeAlias = str | Callable[[], _HashObject] | ModuleType | None

openssl_md_meth_names: frozenset[str]

@type_check_only
class _HashObject(Protocol):
@property
def digest_size(self) -> int: ...
@property
def block_size(self) -> int: ...
@property
def name(self) -> str: ...
def copy(self) -> Self: ...
def digest(self) -> bytes: ...
def hexdigest(self) -> str: ...
def update(self, obj: ReadableBuffer, /) -> None: ...

class HASH:
@property
def digest_size(self) -> int: ...
Expand Down
178 changes: 0 additions & 178 deletions crates/red_knot_vendored/vendor/typeshed/stdlib/asyncio/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -410,93 +410,6 @@ if sys.platform == "win32":
"WindowsSelectorEventLoopPolicy", # from windows_events
"WindowsProactorEventLoopPolicy", # from windows_events
)
elif sys.version_info >= (3, 10):
__all__ = (
"BaseEventLoop", # from base_events
"Server", # from base_events
"coroutine", # from coroutines
"iscoroutinefunction", # from coroutines
"iscoroutine", # from coroutines
"AbstractEventLoopPolicy", # from events
"AbstractEventLoop", # from events
"AbstractServer", # from events
"Handle", # from events
"TimerHandle", # from events
"get_event_loop_policy", # from events
"set_event_loop_policy", # from events
"get_event_loop", # from events
"set_event_loop", # from events
"new_event_loop", # from events
"get_child_watcher", # from events
"set_child_watcher", # from events
"_set_running_loop", # from events
"get_running_loop", # from events
"_get_running_loop", # from events
"CancelledError", # from exceptions
"InvalidStateError", # from exceptions
"TimeoutError", # from exceptions
"IncompleteReadError", # from exceptions
"LimitOverrunError", # from exceptions
"SendfileNotAvailableError", # from exceptions
"Future", # from futures
"wrap_future", # from futures
"isfuture", # from futures
"Lock", # from locks
"Event", # from locks
"Condition", # from locks
"Semaphore", # from locks
"BoundedSemaphore", # from locks
"BaseProtocol", # from protocols
"Protocol", # from protocols
"DatagramProtocol", # from protocols
"SubprocessProtocol", # from protocols
"BufferedProtocol", # from protocols
"run", # from runners
"Queue", # from queues
"PriorityQueue", # from queues
"LifoQueue", # from queues
"QueueFull", # from queues
"QueueEmpty", # from queues
"StreamReader", # from streams
"StreamWriter", # from streams
"StreamReaderProtocol", # from streams
"open_connection", # from streams
"start_server", # from streams
"create_subprocess_exec", # from subprocess
"create_subprocess_shell", # from subprocess
"Task", # from tasks
"create_task", # from tasks
"FIRST_COMPLETED", # from tasks
"FIRST_EXCEPTION", # from tasks
"ALL_COMPLETED", # from tasks
"wait", # from tasks
"wait_for", # from tasks
"as_completed", # from tasks
"sleep", # from tasks
"gather", # from tasks
"shield", # from tasks
"ensure_future", # from tasks
"run_coroutine_threadsafe", # from tasks
"current_task", # from tasks
"all_tasks", # from tasks
"_register_task", # from tasks
"_unregister_task", # from tasks
"_enter_task", # from tasks
"_leave_task", # from tasks
"to_thread", # from threads
"BaseTransport", # from transports
"ReadTransport", # from transports
"WriteTransport", # from transports
"Transport", # from transports
"DatagramTransport", # from transports
"SubprocessTransport", # from transports
"SelectorEventLoop", # from windows_events
"ProactorEventLoop", # from windows_events
"IocpProactor", # from windows_events
"DefaultEventLoopPolicy", # from windows_events
"WindowsSelectorEventLoopPolicy", # from windows_events
"WindowsProactorEventLoopPolicy", # from windows_events
)
elif sys.version_info >= (3, 9):
__all__ = (
"BaseEventLoop", # from base_events
Expand Down Expand Up @@ -1059,97 +972,6 @@ else:
"ThreadedChildWatcher", # from unix_events
"DefaultEventLoopPolicy", # from unix_events
)
elif sys.version_info >= (3, 10):
__all__ = (
"BaseEventLoop", # from base_events
"Server", # from base_events
"coroutine", # from coroutines
"iscoroutinefunction", # from coroutines
"iscoroutine", # from coroutines
"AbstractEventLoopPolicy", # from events
"AbstractEventLoop", # from events
"AbstractServer", # from events
"Handle", # from events
"TimerHandle", # from events
"get_event_loop_policy", # from events
"set_event_loop_policy", # from events
"get_event_loop", # from events
"set_event_loop", # from events
"new_event_loop", # from events
"get_child_watcher", # from events
"set_child_watcher", # from events
"_set_running_loop", # from events
"get_running_loop", # from events
"_get_running_loop", # from events
"CancelledError", # from exceptions
"InvalidStateError", # from exceptions
"TimeoutError", # from exceptions
"IncompleteReadError", # from exceptions
"LimitOverrunError", # from exceptions
"SendfileNotAvailableError", # from exceptions
"Future", # from futures
"wrap_future", # from futures
"isfuture", # from futures
"Lock", # from locks
"Event", # from locks
"Condition", # from locks
"Semaphore", # from locks
"BoundedSemaphore", # from locks
"BaseProtocol", # from protocols
"Protocol", # from protocols
"DatagramProtocol", # from protocols
"SubprocessProtocol", # from protocols
"BufferedProtocol", # from protocols
"run", # from runners
"Queue", # from queues
"PriorityQueue", # from queues
"LifoQueue", # from queues
"QueueFull", # from queues
"QueueEmpty", # from queues
"StreamReader", # from streams
"StreamWriter", # from streams
"StreamReaderProtocol", # from streams
"open_connection", # from streams
"start_server", # from streams
"open_unix_connection", # from streams
"start_unix_server", # from streams
"create_subprocess_exec", # from subprocess
"create_subprocess_shell", # from subprocess
"Task", # from tasks
"create_task", # from tasks
"FIRST_COMPLETED", # from tasks
"FIRST_EXCEPTION", # from tasks
"ALL_COMPLETED", # from tasks
"wait", # from tasks
"wait_for", # from tasks
"as_completed", # from tasks
"sleep", # from tasks
"gather", # from tasks
"shield", # from tasks
"ensure_future", # from tasks
"run_coroutine_threadsafe", # from tasks
"current_task", # from tasks
"all_tasks", # from tasks
"_register_task", # from tasks
"_unregister_task", # from tasks
"_enter_task", # from tasks
"_leave_task", # from tasks
"to_thread", # from threads
"BaseTransport", # from transports
"ReadTransport", # from transports
"WriteTransport", # from transports
"Transport", # from transports
"DatagramTransport", # from transports
"SubprocessTransport", # from transports
"SelectorEventLoop", # from unix_events
"AbstractChildWatcher", # from unix_events
"SafeChildWatcher", # from unix_events
"FastChildWatcher", # from unix_events
"PidfdChildWatcher", # from unix_events
"MultiLoopChildWatcher", # from unix_events
"ThreadedChildWatcher", # from unix_events
"DefaultEventLoopPolicy", # from unix_events
)
elif sys.version_info >= (3, 9):
__all__ = (
"BaseEventLoop", # from base_events
Expand Down
44 changes: 30 additions & 14 deletions crates/red_knot_vendored/vendor/typeshed/stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ from _typeshed import (
ConvertibleToFloat,
ConvertibleToInt,
FileDescriptorOrPath,
MaybeNone,
OpenBinaryMode,
OpenBinaryModeReading,
OpenBinaryModeUpdating,
Expand Down Expand Up @@ -95,9 +94,14 @@ _SupportsAnextT = TypeVar("_SupportsAnextT", bound=SupportsAnext[Any], covariant
_AwaitableT = TypeVar("_AwaitableT", bound=Awaitable[Any])
_AwaitableT_co = TypeVar("_AwaitableT_co", bound=Awaitable[Any], covariant=True)
_P = ParamSpec("_P")
_StartT = TypeVar("_StartT", covariant=True, default=Any)
_StopT = TypeVar("_StopT", covariant=True, default=Any)
_StepT = TypeVar("_StepT", covariant=True, default=Any)

# Type variables for slice
_StartT_co = TypeVar("_StartT_co", covariant=True, default=Any) # slice -> slice[Any, Any, Any]
_StopT_co = TypeVar("_StopT_co", covariant=True, default=_StartT_co) # slice[A] -> slice[A, A, A]
# NOTE: step could differ from start and stop, (e.g. datetime/timedelta)l
# the default (start|stop) is chosen to cater to the most common case of int/index slices.
# FIXME: https://github.com/python/typing/issues/213 (replace step=start|stop with step=start&stop)
_StepT_co = TypeVar("_StepT_co", covariant=True, default=_StartT_co | _StopT_co) # slice[A,B] -> slice[A, B, A|B]

class object:
__doc__: str | None
Expand Down Expand Up @@ -940,23 +944,35 @@ class bool(int):
def __invert__(self) -> int: ...

@final
class slice(Generic[_StartT, _StopT, _StepT]):
class slice(Generic[_StartT_co, _StopT_co, _StepT_co]):
@property
def start(self) -> _StartT: ...
def start(self) -> _StartT_co: ...
@property
def step(self) -> _StepT: ...
def step(self) -> _StepT_co: ...
@property
def stop(self) -> _StopT: ...
@overload
def __new__(cls, stop: int | None, /) -> slice[int | MaybeNone, int | MaybeNone, int | MaybeNone]: ...
def stop(self) -> _StopT_co: ...
# Note: __new__ overloads map `None` to `Any`, since users expect slice(x, None)
# to be compatible with slice(None, x).
# generic slice --------------------------------------------------------------------
@overload
def __new__(
cls, start: int | None, stop: int | None, step: int | None = None, /
) -> slice[int | MaybeNone, int | MaybeNone, int | MaybeNone]: ...
def __new__(cls, start: None, stop: None = None, step: None = None, /) -> slice[Any, Any, Any]: ...
# unary overloads ------------------------------------------------------------------
@overload
def __new__(cls, stop: _T2, /) -> slice[Any, _T2, Any]: ...
# binary overloads -----------------------------------------------------------------
@overload
def __new__(cls, start: _T1, stop: None, step: None = None, /) -> slice[_T1, Any, Any]: ...
@overload
def __new__(cls, start: None, stop: _T2, step: None = None, /) -> slice[Any, _T2, Any]: ...
@overload
def __new__(cls, start: _T1, stop: _T2, step: None = None, /) -> slice[_T1, _T2, Any]: ...
# ternary overloads ----------------------------------------------------------------
@overload
def __new__(cls, start: None, stop: None, step: _T3, /) -> slice[Any, Any, _T3]: ...
@overload
def __new__(cls, start: _T1, stop: None, step: _T3, /) -> slice[_T1, Any, _T3]: ...
@overload
def __new__(cls, start: _T1, stop: _T2, /) -> slice[_T1, _T2, Any]: ...
def __new__(cls, start: None, stop: _T2, step: _T3, /) -> slice[Any, _T2, _T3]: ...
@overload
def __new__(cls, start: _T1, stop: _T2, step: _T3, /) -> slice[_T1, _T2, _T3]: ...
def __eq__(self, value: object, /) -> bool: ...
Expand Down
25 changes: 23 additions & 2 deletions crates/red_knot_vendored/vendor/typeshed/stdlib/codecs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ from _codecs import *
from _typeshed import ReadableBuffer
from abc import abstractmethod
from collections.abc import Callable, Generator, Iterable
from typing import Any, BinaryIO, ClassVar, Final, Literal, Protocol, TextIO
from typing_extensions import Self
from typing import Any, BinaryIO, ClassVar, Final, Literal, Protocol, TextIO, overload
from typing_extensions import Self, TypeAlias

__all__ = [
"register",
Expand Down Expand Up @@ -58,6 +58,21 @@ BOM32_LE: Final = b"\xff\xfe"
BOM64_BE: Final = b"\x00\x00\xfe\xff"
BOM64_LE: Final = b"\xff\xfe\x00\x00"

_BufferedEncoding: TypeAlias = Literal[
"idna",
"raw-unicode-escape",
"unicode-escape",
"utf-16",
"utf-16-be",
"utf-16-le",
"utf-32",
"utf-32-be",
"utf-32-le",
"utf-7",
"utf-8",
"utf-8-sig",
]

class _WritableStream(Protocol):
def write(self, data: bytes, /) -> object: ...
def seek(self, offset: int, whence: int, /) -> object: ...
Expand Down Expand Up @@ -94,6 +109,9 @@ class _IncrementalEncoder(Protocol):
class _IncrementalDecoder(Protocol):
def __call__(self, errors: str = ...) -> IncrementalDecoder: ...

class _BufferedIncrementalDecoder(Protocol):
def __call__(self, errors: str = ...) -> BufferedIncrementalDecoder: ...

class CodecInfo(tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):
_is_text_encoding: bool
@property
Expand Down Expand Up @@ -125,6 +143,9 @@ class CodecInfo(tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):
def getencoder(encoding: str) -> _Encoder: ...
def getdecoder(encoding: str) -> _Decoder: ...
def getincrementalencoder(encoding: str) -> _IncrementalEncoder: ...
@overload
def getincrementaldecoder(encoding: _BufferedEncoding) -> _BufferedIncrementalDecoder: ...
@overload
def getincrementaldecoder(encoding: str) -> _IncrementalDecoder: ...
def getreader(encoding: str) -> _StreamReader: ...
def getwriter(encoding: str) -> _StreamWriter: ...
Expand Down
Loading

0 comments on commit 0d615b8

Please sign in to comment.