From 942d7f395a821c7b115623a77cc7705fd42cfd44 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 1 Feb 2025 01:01:58 +0000 Subject: [PATCH] Sync vendored typeshed stubs (#15864) Close and reopen this PR to trigger CI Co-authored-by: typeshedbot <> --- .../vendor/typeshed/source_commit.txt | 2 +- .../vendor/typeshed/stdlib/_decimal.pyi | 16 ++++----- .../vendor/typeshed/stdlib/cmath.pyi | 16 ++++----- .../vendor/typeshed/stdlib/contextlib.pyi | 12 ++++--- .../vendor/typeshed/stdlib/decimal.pyi | 22 ++++++------- .../stdlib/importlib/resources/_common.pyi | 2 +- .../vendor/typeshed/stdlib/inspect.pyi | 6 ++-- .../vendor/typeshed/stdlib/ipaddress.pyi | 2 +- .../vendor/typeshed/stdlib/json/encoder.pyi | 10 +++--- .../vendor/typeshed/stdlib/json/scanner.pyi | 4 +++ .../vendor/typeshed/stdlib/math.pyi | 12 +++---- .../vendor/typeshed/stdlib/optparse.pyi | 33 +++++++++---------- .../vendor/typeshed/stdlib/sys/__init__.pyi | 1 + .../vendor/typeshed/stdlib/tokenize.pyi | 5 ++- .../vendor/typeshed/stdlib/types.pyi | 1 + 15 files changed, 75 insertions(+), 69 deletions(-) diff --git a/crates/red_knot_vendored/vendor/typeshed/source_commit.txt b/crates/red_knot_vendored/vendor/typeshed/source_commit.txt index 7efc9fc27d5b49..9d991f454c556c 100644 --- a/crates/red_knot_vendored/vendor/typeshed/source_commit.txt +++ b/crates/red_knot_vendored/vendor/typeshed/source_commit.txt @@ -1 +1 @@ -101287091cbd71a3305a4fc4a1a8eb5df0e3f6f7 +c193cd2a36839c8e6336f350397f51ce52fedd5e diff --git a/crates/red_knot_vendored/vendor/typeshed/stdlib/_decimal.pyi b/crates/red_knot_vendored/vendor/typeshed/stdlib/_decimal.pyi index cdd0268a1bdffe..06c0197dcf07c8 100644 --- a/crates/red_knot_vendored/vendor/typeshed/stdlib/_decimal.pyi +++ b/crates/red_knot_vendored/vendor/typeshed/stdlib/_decimal.pyi @@ -27,14 +27,14 @@ _TrapType: TypeAlias = type[DecimalException] __version__: Final[str] __libmpdec_version__: Final[str] -ROUND_DOWN: Final[str] -ROUND_HALF_UP: Final[str] -ROUND_HALF_EVEN: Final[str] -ROUND_CEILING: Final[str] -ROUND_FLOOR: Final[str] -ROUND_UP: Final[str] -ROUND_HALF_DOWN: Final[str] -ROUND_05UP: Final[str] +ROUND_DOWN: Final = "ROUND_DOWN" +ROUND_HALF_UP: Final = "ROUND_HALF_UP" +ROUND_HALF_EVEN: Final = "ROUND_HALF_EVEN" +ROUND_CEILING: Final = "ROUND_CEILING" +ROUND_FLOOR: Final = "ROUND_FLOOR" +ROUND_UP: Final = "ROUND_UP" +ROUND_HALF_DOWN: Final = "ROUND_HALF_DOWN" +ROUND_05UP: Final = "ROUND_05UP" HAVE_CONTEXTVAR: Final[bool] HAVE_THREADS: Final[bool] MAX_EMAX: Final[int] diff --git a/crates/red_knot_vendored/vendor/typeshed/stdlib/cmath.pyi b/crates/red_knot_vendored/vendor/typeshed/stdlib/cmath.pyi index fab9d10230f841..a08addcf543895 100644 --- a/crates/red_knot_vendored/vendor/typeshed/stdlib/cmath.pyi +++ b/crates/red_knot_vendored/vendor/typeshed/stdlib/cmath.pyi @@ -1,13 +1,13 @@ -from typing import SupportsComplex, SupportsFloat, SupportsIndex +from typing import Final, SupportsComplex, SupportsFloat, SupportsIndex from typing_extensions import TypeAlias -e: float -pi: float -inf: float -infj: complex -nan: float -nanj: complex -tau: float +e: Final[float] +pi: Final[float] +inf: Final[float] +infj: Final[complex] +nan: Final[float] +nanj: Final[complex] +tau: Final[float] _C: TypeAlias = SupportsFloat | SupportsComplex | SupportsIndex | complex diff --git a/crates/red_knot_vendored/vendor/typeshed/stdlib/contextlib.pyi b/crates/red_knot_vendored/vendor/typeshed/stdlib/contextlib.pyi index f57e7fa670360f..e1d5f91faf5be0 100644 --- a/crates/red_knot_vendored/vendor/typeshed/stdlib/contextlib.pyi +++ b/crates/red_knot_vendored/vendor/typeshed/stdlib/contextlib.pyi @@ -32,9 +32,9 @@ _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) _T_io = TypeVar("_T_io", bound=IO[str] | None) _ExitT_co = TypeVar("_ExitT_co", covariant=True, bound=bool | None, default=bool | None) -_F = TypeVar("_F", bound=Callable[..., Any]) _G = TypeVar("_G", bound=Generator[Any, Any, Any] | AsyncGenerator[Any, Any], covariant=True) _P = ParamSpec("_P") +_R = TypeVar("_R") _SendT_contra = TypeVar("_SendT_contra", contravariant=True, default=None) _ReturnT_co = TypeVar("_ReturnT_co", covariant=True, default=None) @@ -64,9 +64,13 @@ class AbstractAsyncContextManager(ABC, Protocol[_T_co, _ExitT_co]): # type: ign self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None, / ) -> _ExitT_co: ... +class _WrappedCallable(Generic[_P, _R]): + __wrapped__: Callable[_P, _R] + def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R: ... + class ContextDecorator: def _recreate_cm(self) -> Self: ... - def __call__(self, func: _F) -> _F: ... + def __call__(self, func: Callable[_P, _R]) -> _WrappedCallable[_P, _R]: ... class _GeneratorContextManagerBase(Generic[_G]): # Ideally this would use ParamSpec, but that requires (*args, **kwargs), which this isn't. see #6676 @@ -93,11 +97,11 @@ class _GeneratorContextManager( def contextmanager(func: Callable[_P, Iterator[_T_co]]) -> Callable[_P, _GeneratorContextManager[_T_co]]: ... if sys.version_info >= (3, 10): - _AF = TypeVar("_AF", bound=Callable[..., Awaitable[Any]]) + _AR = TypeVar("_AR", bound=Awaitable[Any]) class AsyncContextDecorator: def _recreate_cm(self) -> Self: ... - def __call__(self, func: _AF) -> _AF: ... + def __call__(self, func: Callable[_P, _AR]) -> _WrappedCallable[_P, _AR]: ... class _AsyncGeneratorContextManager( _GeneratorContextManagerBase[AsyncGenerator[_T_co, _SendT_contra]], diff --git a/crates/red_knot_vendored/vendor/typeshed/stdlib/decimal.pyi b/crates/red_knot_vendored/vendor/typeshed/stdlib/decimal.pyi index 7eb922c8a7ed31..4ded21e0b017ee 100644 --- a/crates/red_knot_vendored/vendor/typeshed/stdlib/decimal.pyi +++ b/crates/red_knot_vendored/vendor/typeshed/stdlib/decimal.pyi @@ -65,7 +65,7 @@ class Underflow(Inexact, Rounded, Subnormal): ... class FloatOperation(DecimalException, TypeError): ... class Decimal: - def __new__(cls, value: _DecimalNew = ..., context: Context | None = ...) -> Self: ... + def __new__(cls, value: _DecimalNew = "0", context: Context | None = None) -> Self: ... @classmethod def from_float(cls, f: float, /) -> Self: ... def __bool__(self) -> bool: ... @@ -163,12 +163,12 @@ class Decimal: def __reduce__(self) -> tuple[type[Self], tuple[str]]: ... def __copy__(self) -> Self: ... def __deepcopy__(self, memo: Any, /) -> Self: ... - def __format__(self, specifier: str, context: Context | None = ..., /) -> str: ... + def __format__(self, specifier: str, context: Context | None = None, /) -> str: ... class Context: # TODO: Context doesn't allow you to delete *any* attributes from instances of the class at runtime, # even settable attributes like `prec` and `rounding`, - # but that's inexpressable in the stub. + # but that's inexpressible in the stub. # Type checkers either ignore it or misinterpret it # if you add a `def __delattr__(self, name: str, /) -> NoReturn` method to the stub prec: int @@ -181,14 +181,14 @@ class Context: flags: dict[_TrapType, bool] def __init__( self, - prec: int | None = ..., - rounding: str | None = ..., - Emin: int | None = ..., - Emax: int | None = ..., - capitals: int | None = ..., - clamp: int | None = ..., - flags: None | dict[_TrapType, bool] | Container[_TrapType] = ..., - traps: None | dict[_TrapType, bool] | Container[_TrapType] = ..., + prec: int | None = None, + rounding: str | None = None, + Emin: int | None = None, + Emax: int | None = None, + capitals: int | None = None, + clamp: int | None = None, + flags: dict[_TrapType, bool] | Container[_TrapType] | None = None, + traps: dict[_TrapType, bool] | Container[_TrapType] | None = None, ) -> None: ... def __reduce__(self) -> tuple[type[Self], tuple[Any, ...]]: ... def clear_flags(self) -> None: ... diff --git a/crates/red_knot_vendored/vendor/typeshed/stdlib/importlib/resources/_common.pyi b/crates/red_knot_vendored/vendor/typeshed/stdlib/importlib/resources/_common.pyi index f04f70f25e230f..f1056f62ed6e0a 100644 --- a/crates/red_knot_vendored/vendor/typeshed/stdlib/importlib/resources/_common.pyi +++ b/crates/red_knot_vendored/vendor/typeshed/stdlib/importlib/resources/_common.pyi @@ -16,7 +16,7 @@ if sys.version_info >= (3, 11): Anchor: TypeAlias = Package def package_to_anchor( - func: Callable[[Anchor | None], Traversable] + func: Callable[[Anchor | None], Traversable], ) -> Callable[[Anchor | None, Anchor | None], Traversable]: ... @overload def files(anchor: Anchor | None = None) -> Traversable: ... diff --git a/crates/red_knot_vendored/vendor/typeshed/stdlib/inspect.pyi b/crates/red_knot_vendored/vendor/typeshed/stdlib/inspect.pyi index c6836c837eaa60..43b3dd52988744 100644 --- a/crates/red_knot_vendored/vendor/typeshed/stdlib/inspect.pyi +++ b/crates/red_knot_vendored/vendor/typeshed/stdlib/inspect.pyi @@ -370,7 +370,7 @@ if sys.version_info >= (3, 12): AGEN_CLOSED: Final = "AGEN_CLOSED" def getasyncgenstate( - agen: AsyncGenerator[Any, Any] + agen: AsyncGenerator[Any, Any], ) -> Literal["AGEN_CREATED", "AGEN_RUNNING", "AGEN_SUSPENDED", "AGEN_CLOSED"]: ... def getasyncgenlocals(agen: AsyncGeneratorType[Any, Any]) -> dict[str, Any]: ... @@ -590,7 +590,7 @@ GEN_SUSPENDED: Final = "GEN_SUSPENDED" GEN_CLOSED: Final = "GEN_CLOSED" def getgeneratorstate( - generator: Generator[Any, Any, Any] + generator: Generator[Any, Any, Any], ) -> Literal["GEN_CREATED", "GEN_RUNNING", "GEN_SUSPENDED", "GEN_CLOSED"]: ... CORO_CREATED: Final = "CORO_CREATED" @@ -599,7 +599,7 @@ CORO_SUSPENDED: Final = "CORO_SUSPENDED" CORO_CLOSED: Final = "CORO_CLOSED" def getcoroutinestate( - coroutine: Coroutine[Any, Any, Any] + coroutine: Coroutine[Any, Any, Any], ) -> Literal["CORO_CREATED", "CORO_RUNNING", "CORO_SUSPENDED", "CORO_CLOSED"]: ... def getgeneratorlocals(generator: Generator[Any, Any, Any]) -> dict[str, Any]: ... def getcoroutinelocals(coroutine: Coroutine[Any, Any, Any]) -> dict[str, Any]: ... diff --git a/crates/red_knot_vendored/vendor/typeshed/stdlib/ipaddress.pyi b/crates/red_knot_vendored/vendor/typeshed/stdlib/ipaddress.pyi index 0563ed9b00baca..e8e81abc6f79c9 100644 --- a/crates/red_knot_vendored/vendor/typeshed/stdlib/ipaddress.pyi +++ b/crates/red_knot_vendored/vendor/typeshed/stdlib/ipaddress.pyi @@ -18,7 +18,7 @@ def ip_network( address: _RawIPAddress | _RawNetworkPart | tuple[_RawIPAddress] | tuple[_RawIPAddress, int], strict: bool = True ) -> IPv4Network | IPv6Network: ... def ip_interface( - address: _RawIPAddress | _RawNetworkPart | tuple[_RawIPAddress] | tuple[_RawIPAddress, int] + address: _RawIPAddress | _RawNetworkPart | tuple[_RawIPAddress] | tuple[_RawIPAddress, int], ) -> IPv4Interface | IPv6Interface: ... class _IPAddressBase: diff --git a/crates/red_knot_vendored/vendor/typeshed/stdlib/json/encoder.pyi b/crates/red_knot_vendored/vendor/typeshed/stdlib/json/encoder.pyi index aa4a3bdf61d4f0..83b78666d4a703 100644 --- a/crates/red_knot_vendored/vendor/typeshed/stdlib/json/encoder.pyi +++ b/crates/red_knot_vendored/vendor/typeshed/stdlib/json/encoder.pyi @@ -2,11 +2,11 @@ from collections.abc import Callable, Iterator from re import Pattern from typing import Any, Final -ESCAPE: Final[Pattern[str]] -ESCAPE_ASCII: Final[Pattern[str]] -HAS_UTF8: Final[Pattern[bytes]] -ESCAPE_DCT: Final[dict[str, str]] -INFINITY: Final[float] +ESCAPE: Final[Pattern[str]] # undocumented +ESCAPE_ASCII: Final[Pattern[str]] # undocumented +HAS_UTF8: Final[Pattern[bytes]] # undocumented +ESCAPE_DCT: Final[dict[str, str]] # undocumented +INFINITY: Final[float] # undocumented def py_encode_basestring(s: str) -> str: ... # undocumented def py_encode_basestring_ascii(s: str) -> str: ... # undocumented diff --git a/crates/red_knot_vendored/vendor/typeshed/stdlib/json/scanner.pyi b/crates/red_knot_vendored/vendor/typeshed/stdlib/json/scanner.pyi index f3b98996b75239..68b42e92d295e6 100644 --- a/crates/red_knot_vendored/vendor/typeshed/stdlib/json/scanner.pyi +++ b/crates/red_knot_vendored/vendor/typeshed/stdlib/json/scanner.pyi @@ -1,3 +1,7 @@ from _json import make_scanner as make_scanner +from re import Pattern +from typing import Final __all__ = ["make_scanner"] + +NUMBER_RE: Final[Pattern[str]] # undocumented diff --git a/crates/red_knot_vendored/vendor/typeshed/stdlib/math.pyi b/crates/red_knot_vendored/vendor/typeshed/stdlib/math.pyi index 2bb61e0669b4df..86f71f27580a20 100644 --- a/crates/red_knot_vendored/vendor/typeshed/stdlib/math.pyi +++ b/crates/red_knot_vendored/vendor/typeshed/stdlib/math.pyi @@ -1,6 +1,6 @@ import sys from collections.abc import Iterable -from typing import Protocol, SupportsFloat, SupportsIndex, TypeVar, overload +from typing import Final, Protocol, SupportsFloat, SupportsIndex, TypeVar, overload from typing_extensions import TypeAlias _T = TypeVar("_T") @@ -8,11 +8,11 @@ _T_co = TypeVar("_T_co", covariant=True) _SupportsFloatOrIndex: TypeAlias = SupportsFloat | SupportsIndex -e: float -pi: float -inf: float -nan: float -tau: float +e: Final[float] +pi: Final[float] +inf: Final[float] +nan: Final[float] +tau: Final[float] def acos(x: _SupportsFloatOrIndex, /) -> float: ... def acosh(x: _SupportsFloatOrIndex, /) -> float: ... diff --git a/crates/red_knot_vendored/vendor/typeshed/stdlib/optparse.pyi b/crates/red_knot_vendored/vendor/typeshed/stdlib/optparse.pyi index ff5e83cf26db26..583dd0da009e25 100644 --- a/crates/red_knot_vendored/vendor/typeshed/stdlib/optparse.pyi +++ b/crates/red_knot_vendored/vendor/typeshed/stdlib/optparse.pyi @@ -1,8 +1,8 @@ import builtins -from _typeshed import Incomplete, MaybeNone +from _typeshed import MaybeNone, SupportsWrite from abc import abstractmethod from collections.abc import Callable, Iterable, Mapping, Sequence -from typing import IO, Any, AnyStr, ClassVar, Literal, NoReturn, overload +from typing import Any, ClassVar, Literal, NoReturn, overload from typing_extensions import Self __all__ = [ @@ -274,13 +274,13 @@ class OptionParser(OptionContainer): def _add_version_option(self) -> None: ... def _create_option_list(self) -> None: ... def _get_all_options(self) -> list[Option]: ... - def _get_args(self, args: Iterable[Incomplete]) -> list[Incomplete]: ... + def _get_args(self, args: list[str] | None) -> list[str]: ... def _init_parsing_state(self) -> None: ... def _match_long_opt(self, opt: str) -> str: ... - def _populate_option_list(self, option_list: Iterable[Option], add_help: bool = True) -> None: ... - def _process_args(self, largs: list[Incomplete], rargs: list[Incomplete], values: Values) -> None: ... - def _process_long_opt(self, rargs: list[Incomplete], values) -> None: ... - def _process_short_opts(self, rargs: list[Incomplete], values) -> None: ... + def _populate_option_list(self, option_list: Iterable[Option] | None, add_help: bool = True) -> None: ... + def _process_args(self, largs: list[str], rargs: list[str], values: Values) -> None: ... + def _process_long_opt(self, rargs: list[str], values: Values) -> None: ... + def _process_short_opts(self, rargs: list[str], values: Values) -> None: ... @overload def add_option_group(self, opt_group: OptionGroup, /) -> OptionGroup: ... @overload @@ -299,14 +299,11 @@ class OptionParser(OptionContainer): def get_prog_name(self) -> str: ... def get_usage(self) -> str: ... def get_version(self) -> str: ... - @overload - def parse_args(self, args: None = None, values: Values | None = None) -> tuple[Values, list[str]]: ... - @overload - def parse_args(self, args: Sequence[AnyStr], values: Values | None = None) -> tuple[Values, list[AnyStr]]: ... - def print_usage(self, file: IO[str] | None = None) -> None: ... - def print_help(self, file: IO[str] | None = None) -> None: ... - def print_version(self, file: IO[str] | None = None) -> None: ... - def set_default(self, dest, value) -> None: ... - def set_defaults(self, **kwargs) -> None: ... - def set_process_default_values(self, process) -> None: ... - def set_usage(self, usage: str) -> None: ... + def parse_args(self, args: list[str] | None = None, values: Values | None = None) -> tuple[Values, list[str]]: ... + def print_usage(self, file: SupportsWrite[str] | None = None) -> None: ... + def print_help(self, file: SupportsWrite[str] | None = None) -> None: ... + def print_version(self, file: SupportsWrite[str] | None = None) -> None: ... + def set_default(self, dest: str, value: Any) -> None: ... # default value can be "any" type + def set_defaults(self, **kwargs: Any) -> None: ... # default values can be "any" type + def set_process_default_values(self, process: bool) -> None: ... + def set_usage(self, usage: str | None) -> None: ... diff --git a/crates/red_knot_vendored/vendor/typeshed/stdlib/sys/__init__.pyi b/crates/red_knot_vendored/vendor/typeshed/stdlib/sys/__init__.pyi index d11e64d109b537..4aa1699e8b429c 100644 --- a/crates/red_knot_vendored/vendor/typeshed/stdlib/sys/__init__.pyi +++ b/crates/red_knot_vendored/vendor/typeshed/stdlib/sys/__init__.pyi @@ -396,6 +396,7 @@ def intern(string: str, /) -> str: ... if sys.version_info >= (3, 13): def _is_gil_enabled() -> bool: ... + def _clear_internal_caches() -> None: ... def is_finalizing() -> bool: ... def breakpointhook(*args: Any, **kwargs: Any) -> Any: ... diff --git a/crates/red_knot_vendored/vendor/typeshed/stdlib/tokenize.pyi b/crates/red_knot_vendored/vendor/typeshed/stdlib/tokenize.pyi index 7b68f791a8c045..2655f2f0266aac 100644 --- a/crates/red_knot_vendored/vendor/typeshed/stdlib/tokenize.pyi +++ b/crates/red_knot_vendored/vendor/typeshed/stdlib/tokenize.pyi @@ -130,9 +130,8 @@ class Untokenizer: if sys.version_info >= (3, 12): def escape_brackets(self, token: str) -> str: ... -# the docstring says "returns bytes" but is incorrect -- -# if the ENCODING token is missing, it skips the encode -def untokenize(iterable: Iterable[_Token]) -> Any: ... +# Returns str, unless the ENCODING token is present, in which case it returns bytes. +def untokenize(iterable: Iterable[_Token]) -> str | Any: ... def detect_encoding(readline: Callable[[], bytes | bytearray]) -> tuple[str, Sequence[bytes]]: ... def tokenize(readline: Callable[[], bytes | bytearray]) -> Generator[TokenInfo, None, None]: ... def generate_tokens(readline: Callable[[], str]) -> Generator[TokenInfo, None, None]: ... diff --git a/crates/red_knot_vendored/vendor/typeshed/stdlib/types.pyi b/crates/red_knot_vendored/vendor/typeshed/stdlib/types.pyi index b294a0b2f8f75b..d41ca0d1c367e5 100644 --- a/crates/red_knot_vendored/vendor/typeshed/stdlib/types.pyi +++ b/crates/red_knot_vendored/vendor/typeshed/stdlib/types.pyi @@ -640,6 +640,7 @@ if sys.version_info >= (3, 9): def __getitem__(self, typeargs: Any, /) -> GenericAlias: ... def __eq__(self, value: object, /) -> bool: ... def __hash__(self) -> int: ... + def __mro_entries__(self, bases: Iterable[object], /) -> tuple[type, ...]: ... if sys.version_info >= (3, 11): @property def __unpacked__(self) -> bool: ...