Skip to content

Commit

Permalink
Updated typeshed stubs to the latest version.
Browse files Browse the repository at this point in the history
  • Loading branch information
erictraut committed Feb 8, 2025
1 parent 72778de commit ccdf547
Show file tree
Hide file tree
Showing 59 changed files with 599 additions and 468 deletions.
2 changes: 1 addition & 1 deletion packages/pyright-internal/typeshed-fallback/commit.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c2e4ef3ae495272f902071dcf4a0f7701c00c4a2
1d1086018bbd7170c32db60d01da094eee80ca9c
16 changes: 8 additions & 8 deletions packages/pyright-internal/typeshed-fallback/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
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ if sys.platform == "win32":
SO_EXCLUSIVEADDRUSE: int
if sys.platform != "win32":
SO_REUSEPORT: int
if sys.platform != "darwin" or sys.version_info >= (3, 13):
if sys.platform != "darwin":
SO_BINDTODEVICE: int

if sys.platform != "win32" and sys.platform != "darwin":
Expand Down
26 changes: 10 additions & 16 deletions packages/pyright-internal/typeshed-fallback/stdlib/argparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sys
from _typeshed import SupportsWrite, sentinel
from collections.abc import Callable, Generator, Iterable, Sequence
from re import Pattern
from typing import IO, Any, ClassVar, Final, Generic, NewType, NoReturn, Protocol, TypeVar, overload
from typing import IO, Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeVar, overload
from typing_extensions import Self, TypeAlias, deprecated

__all__ = [
Expand Down Expand Up @@ -33,25 +33,14 @@ _ActionT = TypeVar("_ActionT", bound=Action)
_ArgumentParserT = TypeVar("_ArgumentParserT", bound=ArgumentParser)
_N = TypeVar("_N")
_ActionType: TypeAlias = Callable[[str], Any] | FileType | str
# more precisely, Literal["store", "store_const", "store_true",
# "store_false", "append", "append_const", "count", "help", "version",
# "extend"], but using this would make it hard to annotate callers
# that don't use a literal argument
_ActionStr: TypeAlias = str
# more precisely, Literal["?", "*", "+", "...", "A...",
# "==SUPPRESS=="], but using this would make it hard to annotate
# callers that don't use a literal argument
_NArgsStr: TypeAlias = str

ONE_OR_MORE: Final = "+"
OPTIONAL: Final = "?"
PARSER: Final = "A..."
REMAINDER: Final = "..."
_SUPPRESS_T = NewType("_SUPPRESS_T", str)
SUPPRESS: _SUPPRESS_T | str # not using Literal because argparse sometimes compares SUPPRESS with is
# the | str is there so that foo = argparse.SUPPRESS; foo = "test" checks out in mypy
SUPPRESS: Final = "==SUPPRESS=="
ZERO_OR_MORE: Final = "*"
_UNRECOGNIZED_ARGS_ATTR: Final[str] # undocumented
_UNRECOGNIZED_ARGS_ATTR: Final = "_unrecognized_args" # undocumented

class ArgumentError(Exception):
argument_name: str | None
Expand Down Expand Up @@ -86,8 +75,13 @@ class _ActionsContainer:
def add_argument(
self,
*name_or_flags: str,
action: _ActionStr | type[Action] = ...,
nargs: int | _NArgsStr | _SUPPRESS_T | None = None,
# str covers predefined actions ("store_true", "count", etc.)
# and user registered actions via the `register` method.
action: str | type[Action] = ...,
# more precisely, Literal["?", "*", "+", "...", "A...", "==SUPPRESS=="],
# but using this would make it hard to annotate callers that don't use a
# literal argument and for subclasses to override this method.
nargs: int | str | None = None,
const: Any = ...,
default: Any = ...,
type: _ActionType = ...,
Expand Down
7 changes: 6 additions & 1 deletion packages/pyright-internal/typeshed-fallback/stdlib/bdb.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
from _typeshed import ExcInfo, TraceFunction, Unused
from collections.abc import Callable, Iterable, Mapping
from collections.abc import Callable, Iterable, Iterator, Mapping
from contextlib import contextmanager
from types import CodeType, FrameType, TracebackType
from typing import IO, Any, Final, SupportsInt, TypeVar
from typing_extensions import ParamSpec
Expand Down Expand Up @@ -30,6 +31,10 @@ class Bdb:
def __init__(self, skip: Iterable[str] | None = None) -> None: ...
def canonic(self, filename: str) -> str: ...
def reset(self) -> None: ...
if sys.version_info >= (3, 12):
@contextmanager
def set_enterframe(self, frame: FrameType) -> Iterator[None]: ...

def trace_dispatch(self, frame: FrameType, event: str, arg: Any) -> TraceFunction: ...
def dispatch_line(self, frame: FrameType) -> TraceFunction: ...
def dispatch_call(self, frame: FrameType, arg: None) -> TraceFunction: ...
Expand Down
16 changes: 8 additions & 8 deletions packages/pyright-internal/typeshed-fallback/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
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 packages/pyright-internal/typeshed-fallback/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
@@ -1,3 +1,4 @@
import sys
from collections.abc import Iterable, Iterator
from email.errors import HeaderParseError, MessageDefect
from email.policy import Policy
Expand All @@ -21,6 +22,9 @@ NLSET: Final[set[str]]
# Added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5
SPECIALSNL: Final[set[str]]

if sys.version_info >= (3, 12):
def make_quoted_pairs(value: Any) -> str: ...

def quote_string(value: Any) -> str: ...

rfc2047_matcher: Pattern[str]
Expand Down
6 changes: 5 additions & 1 deletion packages/pyright-internal/typeshed-fallback/stdlib/enum.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ if sys.version_info >= (3, 11):
def __init__(self, value: _EnumMemberT) -> None: ...

class _EnumDict(dict[str, Any]):
def __init__(self) -> None: ...
if sys.version_info >= (3, 13):
def __init__(self, cls_name: str | None = None) -> None: ...
else:
def __init__(self) -> None: ...

def __setitem__(self, key: str, value: Any) -> None: ...
if sys.version_info >= (3, 11):
# See comment above `typing.MutableMapping.update`
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
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
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
12 changes: 6 additions & 6 deletions packages/pyright-internal/typeshed-fallback/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
41 changes: 19 additions & 22 deletions packages/pyright-internal/typeshed-fallback/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, Final, Literal, NoReturn, overload
from typing_extensions import Self

__all__ = [
Expand All @@ -24,10 +24,10 @@ __all__ = [
"BadOptionError",
"check_choice",
]

NO_DEFAULT: tuple[str, ...]
SUPPRESS_HELP: str
SUPPRESS_USAGE: str
# pytype is not happy with `NO_DEFAULT: Final = ("NO", "DEFAULT")`
NO_DEFAULT: Final[tuple[Literal["NO"], Literal["DEFAULT"]]]
SUPPRESS_HELP: Final = "SUPPRESSHELP"
SUPPRESS_USAGE: Final = "SUPPRESSUSAGE"

# Can return complex, float, or int depending on the option's type
def check_builtin(option: Option, opt: str, value: str) -> complex: ...
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: ...
Loading

0 comments on commit ccdf547

Please sign in to comment.