Skip to content

Commit

Permalink
Sync vendored typeshed stubs (#15864)
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 Feb 1, 2025
1 parent b58f2c3 commit 942d7f3
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 69 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 @@
101287091cbd71a3305a4fc4a1a8eb5df0e3f6f7
c193cd2a36839c8e6336f350397f51ce52fedd5e
16 changes: 8 additions & 8 deletions crates/red_knot_vendored/vendor/typeshed/stdlib/_decimal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
16 changes: 8 additions & 8 deletions crates/red_knot_vendored/vendor/typeshed/stdlib/cmath.pyi
Original file line number Diff line number Diff line change
@@ -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

Expand Down
12 changes: 8 additions & 4 deletions crates/red_knot_vendored/vendor/typeshed/stdlib/contextlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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]],
Expand Down
22 changes: 11 additions & 11 deletions crates/red_knot_vendored/vendor/typeshed/stdlib/decimal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down Expand Up @@ -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
Expand All @@ -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: ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
6 changes: 3 additions & 3 deletions crates/red_knot_vendored/vendor/typeshed/stdlib/inspect.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]: ...

Expand Down Expand Up @@ -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"
Expand All @@ -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]: ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions crates/red_knot_vendored/vendor/typeshed/stdlib/json/encoder.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions crates/red_knot_vendored/vendor/typeshed/stdlib/math.pyi
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
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")
_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: ...
Expand Down
33 changes: 15 additions & 18 deletions crates/red_knot_vendored/vendor/typeshed/stdlib/optparse.pyi
Original file line number Diff line number Diff line change
@@ -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__ = [
Expand Down Expand Up @@ -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
Expand All @@ -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: ...
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
5 changes: 2 additions & 3 deletions crates/red_knot_vendored/vendor/typeshed/stdlib/tokenize.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]: ...
Expand Down
1 change: 1 addition & 0 deletions crates/red_knot_vendored/vendor/typeshed/stdlib/types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down

0 comments on commit 942d7f3

Please sign in to comment.