diff --git a/mypy/typeshed/stdlib/_sitebuiltins.pyi b/mypy/typeshed/stdlib/_sitebuiltins.pyi index 49e88a196825..eb6c81129421 100644 --- a/mypy/typeshed/stdlib/_sitebuiltins.pyi +++ b/mypy/typeshed/stdlib/_sitebuiltins.pyi @@ -1,3 +1,4 @@ +import sys from collections.abc import Iterable from typing import ClassVar, Literal, NoReturn @@ -5,7 +6,7 @@ class Quitter: name: str eof: str def __init__(self, name: str, eof: str) -> None: ... - def __call__(self, code: int | None = None) -> NoReturn: ... + def __call__(self, code: sys._ExitCode = None) -> NoReturn: ... class _Printer: MAXLINES: ClassVar[Literal[23]] @@ -13,4 +14,4 @@ class _Printer: def __call__(self) -> None: ... class _Helper: - def __call__(self, request: object) -> None: ... + def __call__(self, request: object = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/asyncio/proactor_events.pyi b/mypy/typeshed/stdlib/asyncio/proactor_events.pyi index 957fdd6ce255..909d671df289 100644 --- a/mypy/typeshed/stdlib/asyncio/proactor_events.pyi +++ b/mypy/typeshed/stdlib/asyncio/proactor_events.pyi @@ -62,3 +62,4 @@ class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePip class BaseProactorEventLoop(base_events.BaseEventLoop): def __init__(self, proactor: Any) -> None: ... + async def sock_recv(self, sock: socket, n: int) -> bytes: ... diff --git a/mypy/typeshed/stdlib/asyncio/selector_events.pyi b/mypy/typeshed/stdlib/asyncio/selector_events.pyi index 430f2dd405cd..18c5df033e2f 100644 --- a/mypy/typeshed/stdlib/asyncio/selector_events.pyi +++ b/mypy/typeshed/stdlib/asyncio/selector_events.pyi @@ -1,4 +1,5 @@ import selectors +from socket import socket from . import base_events @@ -6,3 +7,4 @@ __all__ = ("BaseSelectorEventLoop",) class BaseSelectorEventLoop(base_events.BaseEventLoop): def __init__(self, selector: selectors.BaseSelector | None = None) -> None: ... + async def sock_recv(self, sock: socket, n: int) -> bytes: ... diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi index 1a4ca925168a..5c6d321f772e 100644 --- a/mypy/typeshed/stdlib/builtins.pyi +++ b/mypy/typeshed/stdlib/builtins.pyi @@ -1,5 +1,6 @@ # ruff: noqa: PYI036 # This is the module declaring BaseException import _ast +import _sitebuiltins import _typeshed import sys import types @@ -46,7 +47,6 @@ from typing import ( # noqa: Y022 Mapping, MutableMapping, MutableSequence, - NoReturn, Protocol, Sequence, SupportsAbs, @@ -1264,8 +1264,10 @@ def compile( *, _feature_version: int = -1, ) -> Any: ... -def copyright() -> None: ... -def credits() -> None: ... + +copyright: _sitebuiltins._Printer +credits: _sitebuiltins._Printer + def delattr(obj: object, name: str, /) -> None: ... def dir(o: object = ..., /) -> list[str]: ... @overload @@ -1320,7 +1322,7 @@ else: /, ) -> None: ... -def exit(code: sys._ExitCode = None) -> NoReturn: ... +exit: _sitebuiltins.Quitter class filter(Generic[_T]): @overload @@ -1354,7 +1356,9 @@ def getattr(o: object, name: str, default: _T, /) -> Any | _T: ... def globals() -> dict[str, Any]: ... def hasattr(obj: object, name: str, /) -> bool: ... def hash(obj: object, /) -> int: ... -def help(request: object = ...) -> None: ... + +help: _sitebuiltins._Helper + def hex(number: int | SupportsIndex, /) -> str: ... def id(obj: object, /) -> int: ... def input(prompt: object = "", /) -> str: ... @@ -1380,7 +1384,9 @@ else: def isinstance(obj: object, class_or_tuple: _ClassInfo, /) -> bool: ... def issubclass(cls: type, class_or_tuple: _ClassInfo, /) -> bool: ... def len(obj: Sized, /) -> int: ... -def license() -> None: ... + +license: _sitebuiltins._Printer + def locals() -> dict[str, Any]: ... class map(Generic[_S]): @@ -1623,7 +1629,8 @@ def pow(base: _SupportsPow3[_E, _M, _T_co], exp: _E, mod: _M) -> _T_co: ... def pow(base: _SupportsSomeKindOfPow, exp: float, mod: None = None) -> Any: ... @overload def pow(base: _SupportsSomeKindOfPow, exp: complex, mod: None = None) -> complex: ... -def quit(code: sys._ExitCode = None) -> NoReturn: ... + +quit: _sitebuiltins.Quitter class reversed(Generic[_T]): @overload diff --git a/mypy/typeshed/stdlib/ctypes/__init__.pyi b/mypy/typeshed/stdlib/ctypes/__init__.pyi index 3e0e7c45bf15..a15dd3615c0c 100644 --- a/mypy/typeshed/stdlib/ctypes/__init__.pyi +++ b/mypy/typeshed/stdlib/ctypes/__init__.pyi @@ -47,7 +47,7 @@ class ArgumentError(Exception): ... class CDLL: _func_flags_: ClassVar[int] - _func_restype_: ClassVar[_CDataType] + _func_restype_: ClassVar[type[_CDataType]] _name: str _handle: int _FuncPtr: type[_FuncPointer] @@ -202,7 +202,10 @@ if sys.platform == "win32": class HRESULT(_SimpleCData[int]): ... # TODO undocumented if sys.version_info >= (3, 12): - c_time_t: type[c_int32 | c_int64] # alias for one or the other at runtime + # At runtime, this is an alias for either c_int32 or c_int64, + # which are themselves an alias for one of c_short, c_int, c_long, or c_longlong + # This covers all our bases. + c_time_t: type[c_int32 | c_int64 | c_short | c_int | c_long | c_longlong] class py_object(_CanCastTo, _SimpleCData[_T]): ... diff --git a/mypy/typeshed/stdlib/fractions.pyi b/mypy/typeshed/stdlib/fractions.pyi index fbcfa868cc1b..33bc766df15d 100644 --- a/mypy/typeshed/stdlib/fractions.pyi +++ b/mypy/typeshed/stdlib/fractions.pyi @@ -27,11 +27,11 @@ class Fraction(Rational): @overload def __new__(cls, numerator: int | Rational = 0, denominator: int | Rational | None = None) -> Self: ... @overload - def __new__(cls, value: float | Decimal | str, /) -> Self: ... + def __new__(cls, numerator: float | Decimal | str) -> Self: ... if sys.version_info >= (3, 14): @overload - def __new__(cls, value: _ConvertibleToIntegerRatio) -> Self: ... + def __new__(cls, numerator: _ConvertibleToIntegerRatio) -> Self: ... @classmethod def from_float(cls, f: float) -> Self: ... diff --git a/mypy/typeshed/stdlib/optparse.pyi b/mypy/typeshed/stdlib/optparse.pyi index d6db7a06f291..6096ac4a2a1d 100644 --- a/mypy/typeshed/stdlib/optparse.pyi +++ b/mypy/typeshed/stdlib/optparse.pyi @@ -182,6 +182,8 @@ class Values: def ensure_value(self, attr: str, value): ... def read_file(self, filename: str, mode: str = "careful") -> None: ... def read_module(self, modname: str, mode: str = "careful") -> None: ... + # __getattr__ doesn't exist, but anything passed as a default to __init__ + # is set on the instance. def __getattr__(self, name: str): ... def __setattr__(self, name: str, value, /) -> None: ... def __eq__(self, other: object) -> bool: ... diff --git a/mypy/typeshed/stdlib/os/__init__.pyi b/mypy/typeshed/stdlib/os/__init__.pyi index 98260b14e7ed..64691b514a48 100644 --- a/mypy/typeshed/stdlib/os/__init__.pyi +++ b/mypy/typeshed/stdlib/os/__init__.pyi @@ -231,6 +231,7 @@ if sys.platform == "linux" and sys.version_info >= (3, 12): "CLONE_NEWNET", "CLONE_NEWNS", "CLONE_NEWPID", + "CLONE_NEWTIME", "CLONE_NEWUSER", "CLONE_NEWUTS", "CLONE_SIGHAND", diff --git a/mypy/typeshed/stdlib/traceback.pyi b/mypy/typeshed/stdlib/traceback.pyi index 1c4a59de66aa..e36081acfa03 100644 --- a/mypy/typeshed/stdlib/traceback.pyi +++ b/mypy/typeshed/stdlib/traceback.pyi @@ -115,6 +115,8 @@ if sys.version_info >= (3, 11): class TracebackException: __cause__: TracebackException __context__: TracebackException + if sys.version_info >= (3, 11): + exceptions: list[TracebackException] | None __suppress_context__: bool stack: StackSummary filename: str