Skip to content

Commit

Permalink
Sync typeshed (#18294)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Dec 15, 2024
1 parent ce14043 commit be87d3d
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 13 deletions.
5 changes: 3 additions & 2 deletions mypy/typeshed/stdlib/_sitebuiltins.pyi
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import sys
from collections.abc import Iterable
from typing import ClassVar, Literal, NoReturn

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]]
def __init__(self, name: str, data: str, files: Iterable[str] = (), dirs: Iterable[str] = ()) -> None: ...
def __call__(self) -> None: ...

class _Helper:
def __call__(self, request: object) -> None: ...
def __call__(self, request: object = ...) -> None: ...
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/asyncio/proactor_events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
2 changes: 2 additions & 0 deletions mypy/typeshed/stdlib/asyncio/selector_events.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import selectors
from socket import socket

from . import base_events

__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: ...
21 changes: 14 additions & 7 deletions mypy/typeshed/stdlib/builtins.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ruff: noqa: PYI036 # This is the module declaring BaseException
import _ast
import _sitebuiltins
import _typeshed
import sys
import types
Expand Down Expand Up @@ -46,7 +47,6 @@ from typing import ( # noqa: Y022
Mapping,
MutableMapping,
MutableSequence,
NoReturn,
Protocol,
Sequence,
SupportsAbs,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1320,7 +1322,7 @@ else:
/,
) -> None: ...

def exit(code: sys._ExitCode = None) -> NoReturn: ...
exit: _sitebuiltins.Quitter

class filter(Generic[_T]):
@overload
Expand Down Expand Up @@ -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: ...
Expand All @@ -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]):
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions mypy/typeshed/stdlib/ctypes/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]): ...

Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/fractions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
2 changes: 2 additions & 0 deletions mypy/typeshed/stdlib/optparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/os/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions mypy/typeshed/stdlib/traceback.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit be87d3d

Please sign in to comment.