Sync vendored typeshed stubs (#13753)

This commit is contained in:
github-actions[bot] 2024-10-15 13:36:11 +00:00 committed by GitHub
parent 74bf4b0653
commit 5fa82fb0cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
71 changed files with 4611 additions and 3311 deletions

View file

@ -7339,7 +7339,8 @@ mod tests {
",
)?;
assert_public_ty(&db, "/src/a.py", "a", "str");
// TODO overloads...
assert_public_ty(&db, "/src/a.py", "a", "@Todo");
Ok(())
}

View file

@ -21,7 +21,7 @@ the project the stubs are for, but instead report them here to typeshed.**
Further documentation on stub files, typeshed, and Python's typing system in
general, can also be found at https://typing.readthedocs.io/en/latest/.
Typeshed supports Python versions 3.8 and up.
Typeshed supports Python versions 3.8 to 3.13.
## Using

View file

@ -1 +1 @@
91a58b07cdd807b1d965e04ba85af2adab8bf924
a871efd90ca2734b3341dde98cffab66f3e08cee

View file

@ -20,6 +20,7 @@
__future__: 3.0-
__main__: 3.0-
_ast: 3.0-
_asyncio: 3.0-
_bisect: 3.0-
_bootlocale: 3.4-3.9
_codecs: 3.0-
@ -37,6 +38,7 @@ _imp: 3.0-
_interpchannels: 3.13-
_interpqueues: 3.13-
_interpreters: 3.13-
_io: 3.0-
_json: 3.0-
_locale: 3.0-
_lsprof: 3.0-
@ -50,6 +52,8 @@ _pydecimal: 3.5-
_random: 3.0-
_sitebuiltins: 3.4-
_socket: 3.0- # present in 3.0 at runtime, but not in typeshed
_sqlite3: 3.0-
_ssl: 3.0-
_stat: 3.4-
_thread: 3.0-
_threading_local: 3.0-

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,120 @@
import sys
from asyncio.events import AbstractEventLoop
from collections.abc import Awaitable, Callable, Coroutine, Generator, Iterable
from contextvars import Context
from types import FrameType
from typing import Any, Literal, TextIO, TypeVar
from typing_extensions import Self, TypeAlias
if sys.version_info >= (3, 9):
from types import GenericAlias
_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
_TaskYieldType: TypeAlias = Future[object] | None
class Future(Awaitable[_T], Iterable[_T]):
_state: str
@property
def _exception(self) -> BaseException | None: ...
_blocking: bool
@property
def _log_traceback(self) -> bool: ...
@_log_traceback.setter
def _log_traceback(self, val: Literal[False]) -> None: ...
_asyncio_future_blocking: bool # is a part of duck-typing contract for `Future`
def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ...
def __del__(self) -> None: ...
def get_loop(self) -> AbstractEventLoop: ...
@property
def _callbacks(self) -> list[tuple[Callable[[Self], Any], Context]]: ...
def add_done_callback(self, fn: Callable[[Self], object], /, *, context: Context | None = None) -> None: ...
if sys.version_info >= (3, 9):
def cancel(self, msg: Any | None = None) -> bool: ...
else:
def cancel(self) -> bool: ...
def cancelled(self) -> bool: ...
def done(self) -> bool: ...
def result(self) -> _T: ...
def exception(self) -> BaseException | None: ...
def remove_done_callback(self, fn: Callable[[Self], object], /) -> int: ...
def set_result(self, result: _T, /) -> None: ...
def set_exception(self, exception: type | BaseException, /) -> None: ...
def __iter__(self) -> Generator[Any, None, _T]: ...
def __await__(self) -> Generator[Any, None, _T]: ...
@property
def _loop(self) -> AbstractEventLoop: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
if sys.version_info >= (3, 12):
_TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, _T_co]
elif sys.version_info >= (3, 9):
_TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Coroutine[Any, Any, _T_co]
else:
_TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Awaitable[_T_co]
# mypy and pyright complain that a subclass of an invariant class shouldn't be covariant.
# While this is true in general, here it's sort-of okay to have a covariant subclass,
# since the only reason why `asyncio.Future` is invariant is the `set_result()` method,
# and `asyncio.Task.set_result()` always raises.
class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportInvalidTypeArguments]
if sys.version_info >= (3, 12):
def __init__(
self,
coro: _TaskCompatibleCoro[_T_co],
*,
loop: AbstractEventLoop = ...,
name: str | None = ...,
context: Context | None = None,
eager_start: bool = False,
) -> None: ...
elif sys.version_info >= (3, 11):
def __init__(
self,
coro: _TaskCompatibleCoro[_T_co],
*,
loop: AbstractEventLoop = ...,
name: str | None = ...,
context: Context | None = None,
) -> None: ...
else:
def __init__(
self, coro: _TaskCompatibleCoro[_T_co], *, loop: AbstractEventLoop = ..., name: str | None = ...
) -> None: ...
if sys.version_info >= (3, 12):
def get_coro(self) -> _TaskCompatibleCoro[_T_co] | None: ...
else:
def get_coro(self) -> _TaskCompatibleCoro[_T_co]: ...
def get_name(self) -> str: ...
def set_name(self, value: object, /) -> None: ...
if sys.version_info >= (3, 12):
def get_context(self) -> Context: ...
def get_stack(self, *, limit: int | None = None) -> list[FrameType]: ...
def print_stack(self, *, limit: int | None = None, file: TextIO | None = None) -> None: ...
if sys.version_info >= (3, 11):
def cancelling(self) -> int: ...
def uncancel(self) -> int: ...
if sys.version_info < (3, 9):
@classmethod
def current_task(cls, loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
@classmethod
def all_tasks(cls, loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def get_event_loop() -> AbstractEventLoop: ...
def get_running_loop() -> AbstractEventLoop: ...
def _set_running_loop(loop: AbstractEventLoop | None, /) -> None: ...
def _get_running_loop() -> AbstractEventLoop: ...
def _register_task(task: Task[Any]) -> None: ...
def _unregister_task(task: Task[Any]) -> None: ...
def _enter_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...
def _leave_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...
if sys.version_info >= (3, 12):
def current_task(loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...

View file

@ -20,6 +20,8 @@ _QuotingType: TypeAlias = int
class Error(Exception): ...
_DialectLike: TypeAlias = str | Dialect | type[Dialect]
class Dialect:
delimiter: str
quotechar: str | None
@ -29,9 +31,18 @@ class Dialect:
lineterminator: str
quoting: _QuotingType
strict: bool
def __init__(self) -> None: ...
_DialectLike: TypeAlias = str | Dialect | type[Dialect]
def __init__(
self,
dialect: _DialectLike | None = ...,
delimiter: str = ",",
doublequote: bool = True,
escapechar: str | None = None,
lineterminator: str = "\r\n",
quotechar: str | None = '"',
quoting: _QuotingType = 0,
skipinitialspace: bool = False,
strict: bool = False,
) -> None: ...
class _reader(Iterator[list[str]]):
@property

View file

@ -2,7 +2,7 @@ import sys
from _typeshed import ReadableBuffer, WriteableBuffer
from abc import abstractmethod
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from ctypes import CDLL, ArgumentError as ArgumentError
from ctypes import CDLL, ArgumentError as ArgumentError, c_void_p
from typing import Any, ClassVar, Generic, TypeVar, overload
from typing_extensions import Self, TypeAlias
@ -99,6 +99,9 @@ class _Pointer(_PointerLike, _CData, Generic[_CT]):
def __getitem__(self, key: slice, /) -> list[Any]: ...
def __setitem__(self, key: int, value: Any, /) -> None: ...
@overload
def POINTER(type: None, /) -> type[c_void_p]: ...
@overload
def POINTER(type: type[_CT], /) -> type[_Pointer[_CT]]: ...
def pointer(obj: _CT, /) -> _Pointer[_CT]: ...

View file

@ -298,7 +298,7 @@ if sys.version_info >= (3, 9):
def getmouse() -> tuple[int, int, int, int, int]: ...
def getsyx() -> tuple[int, int]: ...
def getwin(file: SupportsRead[bytes], /) -> _CursesWindow: ...
def getwin(file: SupportsRead[bytes], /) -> window: ...
def halfdelay(tenths: int, /) -> None: ...
def has_colors() -> bool: ...
@ -310,7 +310,7 @@ def has_il() -> bool: ...
def has_key(key: int, /) -> bool: ...
def init_color(color_number: int, r: int, g: int, b: int, /) -> None: ...
def init_pair(pair_number: int, fg: int, bg: int, /) -> None: ...
def initscr() -> _CursesWindow: ...
def initscr() -> window: ...
def intrflush(flag: bool, /) -> None: ...
def is_term_resized(nlines: int, ncols: int, /) -> bool: ...
def isendwin() -> bool: ...
@ -321,8 +321,8 @@ def meta(yes: bool, /) -> None: ...
def mouseinterval(interval: int, /) -> None: ...
def mousemask(newmask: int, /) -> tuple[int, int]: ...
def napms(ms: int, /) -> int: ...
def newpad(nlines: int, ncols: int, /) -> _CursesWindow: ...
def newwin(nlines: int, ncols: int, begin_y: int = ..., begin_x: int = ..., /) -> _CursesWindow: ...
def newpad(nlines: int, ncols: int, /) -> window: ...
def newwin(nlines: int, ncols: int, begin_y: int = ..., begin_x: int = ..., /) -> window: ...
def nl(flag: bool = True, /) -> None: ...
def nocbreak() -> None: ...
def noecho() -> None: ...
@ -378,7 +378,7 @@ def use_env(flag: bool, /) -> None: ...
class error(Exception): ...
@final
class _CursesWindow:
class window: # undocumented
encoding: str
@overload
def addch(self, ch: _ChType, attr: int = ...) -> None: ...
@ -431,9 +431,9 @@ class _CursesWindow:
def delch(self, y: int, x: int) -> None: ...
def deleteln(self) -> None: ...
@overload
def derwin(self, begin_y: int, begin_x: int) -> _CursesWindow: ...
def derwin(self, begin_y: int, begin_x: int) -> window: ...
@overload
def derwin(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> _CursesWindow: ...
def derwin(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> window: ...
def echochar(self, ch: _ChType, attr: int = ..., /) -> None: ...
def enclose(self, y: int, x: int, /) -> bool: ...
def erase(self) -> None: ...
@ -505,16 +505,16 @@ class _CursesWindow:
@overload
def noutrefresh(self, pminrow: int, pmincol: int, sminrow: int, smincol: int, smaxrow: int, smaxcol: int) -> None: ...
@overload
def overlay(self, destwin: _CursesWindow) -> None: ...
def overlay(self, destwin: window) -> None: ...
@overload
def overlay(
self, destwin: _CursesWindow, sminrow: int, smincol: int, dminrow: int, dmincol: int, dmaxrow: int, dmaxcol: int
self, destwin: window, sminrow: int, smincol: int, dminrow: int, dmincol: int, dmaxrow: int, dmaxcol: int
) -> None: ...
@overload
def overwrite(self, destwin: _CursesWindow) -> None: ...
def overwrite(self, destwin: window) -> None: ...
@overload
def overwrite(
self, destwin: _CursesWindow, sminrow: int, smincol: int, dminrow: int, dmincol: int, dmaxrow: int, dmaxcol: int
self, destwin: window, sminrow: int, smincol: int, dminrow: int, dmincol: int, dmaxrow: int, dmaxcol: int
) -> None: ...
def putwin(self, file: IO[Any], /) -> None: ...
def redrawln(self, beg: int, num: int, /) -> None: ...
@ -530,13 +530,13 @@ class _CursesWindow:
def standend(self) -> None: ...
def standout(self) -> None: ...
@overload
def subpad(self, begin_y: int, begin_x: int) -> _CursesWindow: ...
def subpad(self, begin_y: int, begin_x: int) -> window: ...
@overload
def subpad(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> _CursesWindow: ...
def subpad(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> window: ...
@overload
def subwin(self, begin_y: int, begin_x: int) -> _CursesWindow: ...
def subwin(self, begin_y: int, begin_x: int) -> window: ...
@overload
def subwin(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> _CursesWindow: ...
def subwin(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> window: ...
def syncdown(self) -> None: ...
def syncok(self, flag: bool) -> None: ...
def syncup(self) -> None: ...
@ -555,4 +555,3 @@ class _ncurses_version(NamedTuple):
patch: int
ncurses_version: _ncurses_version
window = _CursesWindow # undocumented

View file

@ -1,22 +1,39 @@
import numbers
import sys
from collections.abc import Container, Sequence
from decimal import (
Clamped as Clamped,
Context as Context,
ConversionSyntax as ConversionSyntax,
Decimal as Decimal,
DecimalException as DecimalException,
DecimalTuple as DecimalTuple,
DivisionByZero as DivisionByZero,
DivisionImpossible as DivisionImpossible,
DivisionUndefined as DivisionUndefined,
FloatOperation as FloatOperation,
Inexact as Inexact,
InvalidContext as InvalidContext,
InvalidOperation as InvalidOperation,
Overflow as Overflow,
Rounded as Rounded,
Subnormal as Subnormal,
Underflow as Underflow,
)
from types import TracebackType
from typing import Any, ClassVar, Final, Literal, NamedTuple, overload
from typing_extensions import Self, TypeAlias
from typing import Final
from typing_extensions import TypeAlias
_Decimal: TypeAlias = Decimal | int
_DecimalNew: TypeAlias = Decimal | float | str | tuple[int, Sequence[int], int]
_ComparableNum: TypeAlias = Decimal | float | numbers.Rational
_TrapType: TypeAlias = type[DecimalException]
class _ContextManager:
new_context: Context
saved_context: Context
def __init__(self, new_context: Context) -> None: ...
def __enter__(self) -> Context: ...
def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
__version__: Final[str]
__libmpdec_version__: Final[str]
class DecimalTuple(NamedTuple):
sign: int
digits: tuple[int, ...]
exponent: int | Literal["n", "N", "F"]
ROUND_DOWN: Final[str]
ROUND_HALF_UP: Final[str]
ROUND_HALF_EVEN: Final[str]
@ -32,21 +49,6 @@ MAX_PREC: Final[int]
MIN_EMIN: Final[int]
MIN_ETINY: Final[int]
class DecimalException(ArithmeticError): ...
class Clamped(DecimalException): ...
class InvalidOperation(DecimalException): ...
class ConversionSyntax(InvalidOperation): ...
class DivisionByZero(DecimalException, ZeroDivisionError): ...
class DivisionImpossible(InvalidOperation): ...
class DivisionUndefined(InvalidOperation, ZeroDivisionError): ...
class Inexact(DecimalException): ...
class InvalidContext(InvalidOperation): ...
class Rounded(DecimalException): ...
class Subnormal(DecimalException): ...
class Overflow(Inexact, Rounded): ...
class Underflow(Inexact, Rounded, Subnormal): ...
class FloatOperation(DecimalException, TypeError): ...
def setcontext(context: Context, /) -> None: ...
def getcontext() -> Context: ...
@ -67,215 +69,6 @@ if sys.version_info >= (3, 11):
else:
def localcontext(ctx: Context | None = None) -> _ContextManager: ...
class Decimal:
def __new__(cls, value: _DecimalNew = ..., context: Context | None = ...) -> Self: ...
@classmethod
def from_float(cls, f: float, /) -> Self: ...
def __bool__(self) -> bool: ...
def compare(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def __hash__(self) -> int: ...
def as_tuple(self) -> DecimalTuple: ...
def as_integer_ratio(self) -> tuple[int, int]: ...
def to_eng_string(self, context: Context | None = None) -> str: ...
def __abs__(self) -> Decimal: ...
def __add__(self, value: _Decimal, /) -> Decimal: ...
def __divmod__(self, value: _Decimal, /) -> tuple[Decimal, Decimal]: ...
def __eq__(self, value: object, /) -> bool: ...
def __floordiv__(self, value: _Decimal, /) -> Decimal: ...
def __ge__(self, value: _ComparableNum, /) -> bool: ...
def __gt__(self, value: _ComparableNum, /) -> bool: ...
def __le__(self, value: _ComparableNum, /) -> bool: ...
def __lt__(self, value: _ComparableNum, /) -> bool: ...
def __mod__(self, value: _Decimal, /) -> Decimal: ...
def __mul__(self, value: _Decimal, /) -> Decimal: ...
def __neg__(self) -> Decimal: ...
def __pos__(self) -> Decimal: ...
def __pow__(self, value: _Decimal, mod: _Decimal | None = None, /) -> Decimal: ...
def __radd__(self, value: _Decimal, /) -> Decimal: ...
def __rdivmod__(self, value: _Decimal, /) -> tuple[Decimal, Decimal]: ...
def __rfloordiv__(self, value: _Decimal, /) -> Decimal: ...
def __rmod__(self, value: _Decimal, /) -> Decimal: ...
def __rmul__(self, value: _Decimal, /) -> Decimal: ...
def __rsub__(self, value: _Decimal, /) -> Decimal: ...
def __rtruediv__(self, value: _Decimal, /) -> Decimal: ...
def __sub__(self, value: _Decimal, /) -> Decimal: ...
def __truediv__(self, value: _Decimal, /) -> Decimal: ...
def remainder_near(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def __float__(self) -> float: ...
def __int__(self) -> int: ...
def __trunc__(self) -> int: ...
@property
def real(self) -> Decimal: ...
@property
def imag(self) -> Decimal: ...
def conjugate(self) -> Decimal: ...
def __complex__(self) -> complex: ...
@overload
def __round__(self) -> int: ...
@overload
def __round__(self, ndigits: int, /) -> Decimal: ...
def __floor__(self) -> int: ...
def __ceil__(self) -> int: ...
def fma(self, other: _Decimal, third: _Decimal, context: Context | None = None) -> Decimal: ...
def __rpow__(self, value: _Decimal, mod: Context | None = None, /) -> Decimal: ...
def normalize(self, context: Context | None = None) -> Decimal: ...
def quantize(self, exp: _Decimal, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
def same_quantum(self, other: _Decimal, context: Context | None = None) -> bool: ...
def to_integral_exact(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
def to_integral_value(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
def to_integral(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
def sqrt(self, context: Context | None = None) -> Decimal: ...
def max(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def min(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def adjusted(self) -> int: ...
def canonical(self) -> Decimal: ...
def compare_signal(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def compare_total(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def compare_total_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def copy_abs(self) -> Decimal: ...
def copy_negate(self) -> Decimal: ...
def copy_sign(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def exp(self, context: Context | None = None) -> Decimal: ...
def is_canonical(self) -> bool: ...
def is_finite(self) -> bool: ...
def is_infinite(self) -> bool: ...
def is_nan(self) -> bool: ...
def is_normal(self, context: Context | None = None) -> bool: ...
def is_qnan(self) -> bool: ...
def is_signed(self) -> bool: ...
def is_snan(self) -> bool: ...
def is_subnormal(self, context: Context | None = None) -> bool: ...
def is_zero(self) -> bool: ...
def ln(self, context: Context | None = None) -> Decimal: ...
def log10(self, context: Context | None = None) -> Decimal: ...
def logb(self, context: Context | None = None) -> Decimal: ...
def logical_and(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def logical_invert(self, context: Context | None = None) -> Decimal: ...
def logical_or(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def logical_xor(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def max_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def min_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def next_minus(self, context: Context | None = None) -> Decimal: ...
def next_plus(self, context: Context | None = None) -> Decimal: ...
def next_toward(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def number_class(self, context: Context | None = None) -> str: ...
def radix(self) -> Decimal: ...
def rotate(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def scaleb(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def shift(self, other: _Decimal, context: Context | None = None) -> 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: ...
class _ContextManager:
new_context: Context
saved_context: Context
def __init__(self, new_context: Context) -> None: ...
def __enter__(self) -> Context: ...
def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
_TrapType: TypeAlias = type[DecimalException]
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.
# Type checkers either ignore it or misinterpret it
# if you add a `def __delattr__(self, name: str, /) -> NoReturn` method to the stub
prec: int
rounding: str
Emin: int
Emax: int
capitals: int
clamp: int
traps: dict[_TrapType, bool]
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] = ...,
_ignored_flags: list[_TrapType] | None = ...,
) -> None: ...
def __reduce__(self) -> tuple[type[Self], tuple[Any, ...]]: ...
def clear_flags(self) -> None: ...
def clear_traps(self) -> None: ...
def copy(self) -> Context: ...
def __copy__(self) -> Context: ...
# see https://github.com/python/cpython/issues/94107
__hash__: ClassVar[None] # type: ignore[assignment]
def Etiny(self) -> int: ...
def Etop(self) -> int: ...
def create_decimal(self, num: _DecimalNew = "0", /) -> Decimal: ...
def create_decimal_from_float(self, f: float, /) -> Decimal: ...
def abs(self, x: _Decimal, /) -> Decimal: ...
def add(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def canonical(self, x: Decimal, /) -> Decimal: ...
def compare(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def compare_signal(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def compare_total(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def compare_total_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def copy_abs(self, x: _Decimal, /) -> Decimal: ...
def copy_decimal(self, x: _Decimal, /) -> Decimal: ...
def copy_negate(self, x: _Decimal, /) -> Decimal: ...
def copy_sign(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def divide(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def divide_int(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def divmod(self, x: _Decimal, y: _Decimal, /) -> tuple[Decimal, Decimal]: ...
def exp(self, x: _Decimal, /) -> Decimal: ...
def fma(self, x: _Decimal, y: _Decimal, z: _Decimal, /) -> Decimal: ...
def is_canonical(self, x: _Decimal, /) -> bool: ...
def is_finite(self, x: _Decimal, /) -> bool: ...
def is_infinite(self, x: _Decimal, /) -> bool: ...
def is_nan(self, x: _Decimal, /) -> bool: ...
def is_normal(self, x: _Decimal, /) -> bool: ...
def is_qnan(self, x: _Decimal, /) -> bool: ...
def is_signed(self, x: _Decimal, /) -> bool: ...
def is_snan(self, x: _Decimal, /) -> bool: ...
def is_subnormal(self, x: _Decimal, /) -> bool: ...
def is_zero(self, x: _Decimal, /) -> bool: ...
def ln(self, x: _Decimal, /) -> Decimal: ...
def log10(self, x: _Decimal, /) -> Decimal: ...
def logb(self, x: _Decimal, /) -> Decimal: ...
def logical_and(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def logical_invert(self, x: _Decimal, /) -> Decimal: ...
def logical_or(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def logical_xor(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def max(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def max_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def min(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def min_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def minus(self, x: _Decimal, /) -> Decimal: ...
def multiply(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def next_minus(self, x: _Decimal, /) -> Decimal: ...
def next_plus(self, x: _Decimal, /) -> Decimal: ...
def next_toward(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def normalize(self, x: _Decimal, /) -> Decimal: ...
def number_class(self, x: _Decimal, /) -> str: ...
def plus(self, x: _Decimal, /) -> Decimal: ...
def power(self, a: _Decimal, b: _Decimal, modulo: _Decimal | None = None) -> Decimal: ...
def quantize(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def radix(self) -> Decimal: ...
def remainder(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def remainder_near(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def rotate(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def same_quantum(self, x: _Decimal, y: _Decimal, /) -> bool: ...
def scaleb(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def shift(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def sqrt(self, x: _Decimal, /) -> Decimal: ...
def subtract(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def to_eng_string(self, x: _Decimal, /) -> str: ...
def to_sci_string(self, x: _Decimal, /) -> str: ...
def to_integral_exact(self, x: _Decimal, /) -> Decimal: ...
def to_integral_value(self, x: _Decimal, /) -> Decimal: ...
def to_integral(self, x: _Decimal, /) -> Decimal: ...
DefaultContext: Context
BasicContext: Context
ExtendedContext: Context

View file

@ -0,0 +1,195 @@
import builtins
import codecs
import sys
from _typeshed import FileDescriptorOrPath, MaybeNone, ReadableBuffer, WriteableBuffer
from collections.abc import Callable, Iterable, Iterator
from io import BufferedIOBase, RawIOBase, TextIOBase, UnsupportedOperation as UnsupportedOperation
from os import _Opener
from types import TracebackType
from typing import IO, Any, BinaryIO, Final, Generic, Literal, Protocol, TextIO, TypeVar, overload, type_check_only
from typing_extensions import Self
_T = TypeVar("_T")
DEFAULT_BUFFER_SIZE: Final = 8192
open = builtins.open
def open_code(path: str) -> IO[bytes]: ...
BlockingIOError = builtins.BlockingIOError
class _IOBase:
def __iter__(self) -> Iterator[bytes]: ...
def __next__(self) -> bytes: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
def close(self) -> None: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def readable(self) -> bool: ...
read: Callable[..., Any]
def readlines(self, hint: int = -1, /) -> list[bytes]: ...
def seek(self, offset: int, whence: int = ..., /) -> int: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def truncate(self, size: int | None = ..., /) -> int: ...
def writable(self) -> bool: ...
write: Callable[..., Any]
def writelines(self, lines: Iterable[ReadableBuffer], /) -> None: ...
def readline(self, size: int | None = -1, /) -> bytes: ...
def __del__(self) -> None: ...
@property
def closed(self) -> bool: ...
def _checkClosed(self) -> None: ... # undocumented
class _RawIOBase(_IOBase):
def readall(self) -> bytes: ...
# The following methods can return None if the file is in non-blocking mode
# and no data is available.
def readinto(self, buffer: WriteableBuffer, /) -> int | MaybeNone: ...
def write(self, b: ReadableBuffer, /) -> int | MaybeNone: ...
def read(self, size: int = -1, /) -> bytes | MaybeNone: ...
class _BufferedIOBase(_IOBase):
def detach(self) -> RawIOBase: ...
def readinto(self, buffer: WriteableBuffer, /) -> int: ...
def write(self, buffer: ReadableBuffer, /) -> int: ...
def readinto1(self, buffer: WriteableBuffer, /) -> int: ...
def read(self, size: int | None = ..., /) -> bytes: ...
def read1(self, size: int = ..., /) -> bytes: ...
class FileIO(RawIOBase, _RawIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of writelines in the base classes
mode: str
# The type of "name" equals the argument passed in to the constructor,
# but that can make FileIO incompatible with other I/O types that assume
# "name" is a str. In the future, making FileIO generic might help.
name: Any
def __init__(
self, file: FileDescriptorOrPath, mode: str = ..., closefd: bool = ..., opener: _Opener | None = ...
) -> None: ...
@property
def closefd(self) -> bool: ...
class BytesIO(BufferedIOBase, _BufferedIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of methods in the base classes
def __init__(self, initial_bytes: ReadableBuffer = ...) -> None: ...
# BytesIO does not contain a "name" field. This workaround is necessary
# to allow BytesIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
name: Any
def getvalue(self) -> bytes: ...
def getbuffer(self) -> memoryview: ...
def read1(self, size: int | None = -1, /) -> bytes: ...
class BufferedReader(BufferedIOBase, _BufferedIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of methods in the base classes
raw: RawIOBase
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
def peek(self, size: int = 0, /) -> bytes: ...
class BufferedWriter(BufferedIOBase, _BufferedIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of writelines in the base classes
raw: RawIOBase
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
def write(self, buffer: ReadableBuffer, /) -> int: ...
class BufferedRandom(BufferedReader, BufferedWriter, BufferedIOBase, _BufferedIOBase): # type: ignore[misc] # incompatible definitions of methods in the base classes
def seek(self, target: int, whence: int = 0, /) -> int: ... # stubtest needs this
class BufferedRWPair(BufferedIOBase, _BufferedIOBase):
def __init__(self, reader: RawIOBase, writer: RawIOBase, buffer_size: int = ...) -> None: ...
def peek(self, size: int = ..., /) -> bytes: ...
class _TextIOBase(_IOBase):
encoding: str
errors: str | None
newlines: str | tuple[str, ...] | None
def __iter__(self) -> Iterator[str]: ... # type: ignore[override]
def __next__(self) -> str: ... # type: ignore[override]
def detach(self) -> BinaryIO: ...
def write(self, s: str, /) -> int: ...
def writelines(self, lines: Iterable[str], /) -> None: ... # type: ignore[override]
def readline(self, size: int = ..., /) -> str: ... # type: ignore[override]
def readlines(self, hint: int = -1, /) -> list[str]: ... # type: ignore[override]
def read(self, size: int | None = ..., /) -> str: ...
@type_check_only
class _WrappedBuffer(Protocol):
# "name" is wrapped by TextIOWrapper. Its type is inconsistent between
# the various I/O types, see the comments on TextIOWrapper.name and
# TextIO.name.
@property
def name(self) -> Any: ...
@property
def closed(self) -> bool: ...
def read(self, size: int = ..., /) -> ReadableBuffer: ...
# Optional: def read1(self, size: int, /) -> ReadableBuffer: ...
def write(self, b: bytes, /) -> object: ...
def flush(self) -> object: ...
def close(self) -> object: ...
def seekable(self) -> bool: ...
def readable(self) -> bool: ...
def writable(self) -> bool: ...
def truncate(self, size: int, /) -> int: ...
def fileno(self) -> int: ...
def isatty(self) -> bool: ...
# Optional: Only needs to be present if seekable() returns True.
# def seek(self, offset: Literal[0], whence: Literal[2]) -> int: ...
# def tell(self) -> int: ...
_BufferT_co = TypeVar("_BufferT_co", bound=_WrappedBuffer, default=_WrappedBuffer, covariant=True)
class TextIOWrapper(TextIOBase, _TextIOBase, TextIO, Generic[_BufferT_co]): # type: ignore[misc] # incompatible definitions of write in the base classes
def __init__(
self,
buffer: _BufferT_co,
encoding: str | None = None,
errors: str | None = None,
newline: str | None = None,
line_buffering: bool = False,
write_through: bool = False,
) -> None: ...
# Equals the "buffer" argument passed in to the constructor.
@property
def buffer(self) -> _BufferT_co: ... # type: ignore[override]
@property
def line_buffering(self) -> bool: ...
@property
def write_through(self) -> bool: ...
def reconfigure(
self,
*,
encoding: str | None = None,
errors: str | None = None,
newline: str | None = None,
line_buffering: bool | None = None,
write_through: bool | None = None,
) -> None: ...
def readline(self, size: int = -1, /) -> str: ... # type: ignore[override]
# Equals the "buffer" argument passed in to the constructor.
def detach(self) -> _BufferT_co: ... # type: ignore[override]
# TextIOWrapper's version of seek only supports a limited subset of
# operations.
def seek(self, cookie: int, whence: int = 0, /) -> int: ...
class StringIO(TextIOWrapper, TextIOBase, _TextIOBase): # type: ignore[misc] # incompatible definitions of write in the base classes
def __init__(self, initial_value: str | None = ..., newline: str | None = ...) -> None: ...
# StringIO does not contain a "name" field. This workaround is necessary
# to allow StringIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
name: Any
def getvalue(self) -> str: ...
class IncrementalNewlineDecoder(codecs.IncrementalDecoder):
def __init__(self, decoder: codecs.IncrementalDecoder | None, translate: bool, errors: str = ...) -> None: ...
def decode(self, input: ReadableBuffer | str, final: bool = False) -> str: ...
@property
def newlines(self) -> str | tuple[str, ...] | None: ...
def setstate(self, state: tuple[bytes, int], /) -> None: ...
if sys.version_info >= (3, 10):
@overload
def text_encoding(encoding: None, stacklevel: int = 2, /) -> Literal["locale", "utf-8"]: ...
@overload
def text_encoding(encoding: _T, stacklevel: int = 2, /) -> _T: ...

View file

@ -1,18 +1,16 @@
import sys
from _typeshed import SupportsGetItem
from collections.abc import Callable, Container, Iterable, MutableMapping, MutableSequence, Sequence
from typing import Any, AnyStr, Generic, Protocol, SupportsAbs, SupportsIndex, TypeVar, final, overload
from typing_extensions import ParamSpec, TypeAlias, TypeIs, TypeVarTuple, Unpack
from operator import attrgetter as attrgetter, itemgetter as itemgetter, methodcaller as methodcaller
from typing import Any, AnyStr, Protocol, SupportsAbs, SupportsIndex, TypeVar, overload
from typing_extensions import ParamSpec, TypeAlias, TypeIs
_R = TypeVar("_R")
_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
_T1 = TypeVar("_T1")
_T2 = TypeVar("_T2")
_K = TypeVar("_K")
_V = TypeVar("_V")
_P = ParamSpec("_P")
_Ts = TypeVarTuple("_Ts")
# The following protocols return "Any" instead of bool, since the comparison
# operators can be overloaded to return an arbitrary object. For example,
@ -92,40 +90,6 @@ def setitem(a: MutableSequence[_T], b: slice, c: Sequence[_T], /) -> None: ...
@overload
def setitem(a: MutableMapping[_K, _V], b: _K, c: _V, /) -> None: ...
def length_hint(obj: object, default: int = 0, /) -> int: ...
@final
class attrgetter(Generic[_T_co]):
@overload
def __new__(cls, attr: str, /) -> attrgetter[Any]: ...
@overload
def __new__(cls, attr: str, attr2: str, /) -> attrgetter[tuple[Any, Any]]: ...
@overload
def __new__(cls, attr: str, attr2: str, attr3: str, /) -> attrgetter[tuple[Any, Any, Any]]: ...
@overload
def __new__(cls, attr: str, attr2: str, attr3: str, attr4: str, /) -> attrgetter[tuple[Any, Any, Any, Any]]: ...
@overload
def __new__(cls, attr: str, /, *attrs: str) -> attrgetter[tuple[Any, ...]]: ...
def __call__(self, obj: Any, /) -> _T_co: ...
@final
class itemgetter(Generic[_T_co]):
@overload
def __new__(cls, item: _T, /) -> itemgetter[_T]: ...
@overload
def __new__(cls, item1: _T1, item2: _T2, /, *items: Unpack[_Ts]) -> itemgetter[tuple[_T1, _T2, Unpack[_Ts]]]: ...
# __key: _KT_contra in SupportsGetItem seems to be causing variance issues, ie:
# TypeVar "_KT_contra@SupportsGetItem" is contravariant
# "tuple[int, int]" is incompatible with protocol "SupportsIndex"
# preventing [_T_co, ...] instead of [Any, ...]
#
# A suspected mypy issue prevents using [..., _T] instead of [..., Any] here.
# https://github.com/python/mypy/issues/14032
def __call__(self, obj: SupportsGetItem[Any, Any]) -> Any: ...
@final
class methodcaller:
def __init__(self, name: str, /, *args: Any, **kwargs: Any) -> None: ...
def __call__(self, obj: Any) -> Any: ...
def iadd(a: Any, b: Any, /) -> Any: ...
def iand(a: Any, b: Any, /) -> Any: ...
def iconcat(a: Any, b: Any, /) -> Any: ...

View file

@ -1,6 +1,7 @@
import sys
from _typeshed import ReadableBuffer, WriteableBuffer
from collections.abc import Iterable
from socket import error as error, gaierror as gaierror, herror as herror, timeout as timeout
from typing import Any, SupportsIndex, overload
from typing_extensions import TypeAlias
@ -666,18 +667,6 @@ if sys.platform != "win32":
if sys.platform != "win32" and sys.platform != "darwin":
IPX_TYPE: int
# ===== Exceptions =====
error = OSError
class herror(error): ...
class gaierror(error): ...
if sys.version_info >= (3, 10):
timeout = TimeoutError
else:
class timeout(error): ...
# ===== Classes =====
class socket:
@ -687,8 +676,9 @@ class socket:
def type(self) -> int: ...
@property
def proto(self) -> int: ...
# F811: "Redefinition of unused `timeout`"
@property
def timeout(self) -> float | None: ...
def timeout(self) -> float | None: ... # noqa: F811
if sys.platform == "win32":
def __init__(
self, family: int = ..., type: int = ..., proto: int = ..., fileno: SupportsIndex | bytes | None = ...
@ -788,7 +778,9 @@ def inet_ntoa(packed_ip: ReadableBuffer, /) -> str: ...
def inet_pton(address_family: int, ip_string: str, /) -> bytes: ...
def inet_ntop(address_family: int, packed_ip: ReadableBuffer, /) -> str: ...
def getdefaulttimeout() -> float | None: ...
def setdefaulttimeout(timeout: float | None, /) -> None: ...
# F811: "Redefinition of unused `timeout`"
def setdefaulttimeout(timeout: float | None, /) -> None: ... # noqa: F811
if sys.platform != "win32":
def sethostname(name: str, /) -> None: ...

View file

@ -0,0 +1,312 @@
import sys
from _typeshed import ReadableBuffer, StrOrBytesPath
from collections.abc import Callable
from sqlite3 import (
Connection as Connection,
Cursor as Cursor,
DatabaseError as DatabaseError,
DataError as DataError,
Error as Error,
IntegrityError as IntegrityError,
InterfaceError as InterfaceError,
InternalError as InternalError,
NotSupportedError as NotSupportedError,
OperationalError as OperationalError,
PrepareProtocol as PrepareProtocol,
ProgrammingError as ProgrammingError,
Row as Row,
Warning as Warning,
)
from typing import Any, Final, Literal, TypeVar, overload
from typing_extensions import TypeAlias
if sys.version_info >= (3, 11):
from sqlite3 import Blob as Blob
_T = TypeVar("_T")
_ConnectionT = TypeVar("_ConnectionT", bound=Connection)
_SqliteData: TypeAlias = str | ReadableBuffer | int | float | None
_Adapter: TypeAlias = Callable[[_T], _SqliteData]
_Converter: TypeAlias = Callable[[bytes], Any]
PARSE_COLNAMES: Final[int]
PARSE_DECLTYPES: Final[int]
SQLITE_ALTER_TABLE: Final[int]
SQLITE_ANALYZE: Final[int]
SQLITE_ATTACH: Final[int]
SQLITE_CREATE_INDEX: Final[int]
SQLITE_CREATE_TABLE: Final[int]
SQLITE_CREATE_TEMP_INDEX: Final[int]
SQLITE_CREATE_TEMP_TABLE: Final[int]
SQLITE_CREATE_TEMP_TRIGGER: Final[int]
SQLITE_CREATE_TEMP_VIEW: Final[int]
SQLITE_CREATE_TRIGGER: Final[int]
SQLITE_CREATE_VIEW: Final[int]
SQLITE_CREATE_VTABLE: Final[int]
SQLITE_DELETE: Final[int]
SQLITE_DENY: Final[int]
SQLITE_DETACH: Final[int]
SQLITE_DONE: Final[int]
SQLITE_DROP_INDEX: Final[int]
SQLITE_DROP_TABLE: Final[int]
SQLITE_DROP_TEMP_INDEX: Final[int]
SQLITE_DROP_TEMP_TABLE: Final[int]
SQLITE_DROP_TEMP_TRIGGER: Final[int]
SQLITE_DROP_TEMP_VIEW: Final[int]
SQLITE_DROP_TRIGGER: Final[int]
SQLITE_DROP_VIEW: Final[int]
SQLITE_DROP_VTABLE: Final[int]
SQLITE_FUNCTION: Final[int]
SQLITE_IGNORE: Final[int]
SQLITE_INSERT: Final[int]
SQLITE_OK: Final[int]
SQLITE_PRAGMA: Final[int]
SQLITE_READ: Final[int]
SQLITE_RECURSIVE: Final[int]
SQLITE_REINDEX: Final[int]
SQLITE_SAVEPOINT: Final[int]
SQLITE_SELECT: Final[int]
SQLITE_TRANSACTION: Final[int]
SQLITE_UPDATE: Final[int]
adapters: dict[tuple[type[Any], type[Any]], _Adapter[Any]]
converters: dict[str, _Converter]
sqlite_version: str
if sys.version_info < (3, 12):
version: str
if sys.version_info >= (3, 12):
LEGACY_TRANSACTION_CONTROL: Final[int]
SQLITE_DBCONFIG_DEFENSIVE: Final[int]
SQLITE_DBCONFIG_DQS_DDL: Final[int]
SQLITE_DBCONFIG_DQS_DML: Final[int]
SQLITE_DBCONFIG_ENABLE_FKEY: Final[int]
SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER: Final[int]
SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION: Final[int]
SQLITE_DBCONFIG_ENABLE_QPSG: Final[int]
SQLITE_DBCONFIG_ENABLE_TRIGGER: Final[int]
SQLITE_DBCONFIG_ENABLE_VIEW: Final[int]
SQLITE_DBCONFIG_LEGACY_ALTER_TABLE: Final[int]
SQLITE_DBCONFIG_LEGACY_FILE_FORMAT: Final[int]
SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE: Final[int]
SQLITE_DBCONFIG_RESET_DATABASE: Final[int]
SQLITE_DBCONFIG_TRIGGER_EQP: Final[int]
SQLITE_DBCONFIG_TRUSTED_SCHEMA: Final[int]
SQLITE_DBCONFIG_WRITABLE_SCHEMA: Final[int]
if sys.version_info >= (3, 11):
SQLITE_ABORT: Final[int]
SQLITE_ABORT_ROLLBACK: Final[int]
SQLITE_AUTH: Final[int]
SQLITE_AUTH_USER: Final[int]
SQLITE_BUSY: Final[int]
SQLITE_BUSY_RECOVERY: Final[int]
SQLITE_BUSY_SNAPSHOT: Final[int]
SQLITE_BUSY_TIMEOUT: Final[int]
SQLITE_CANTOPEN: Final[int]
SQLITE_CANTOPEN_CONVPATH: Final[int]
SQLITE_CANTOPEN_DIRTYWAL: Final[int]
SQLITE_CANTOPEN_FULLPATH: Final[int]
SQLITE_CANTOPEN_ISDIR: Final[int]
SQLITE_CANTOPEN_NOTEMPDIR: Final[int]
SQLITE_CANTOPEN_SYMLINK: Final[int]
SQLITE_CONSTRAINT: Final[int]
SQLITE_CONSTRAINT_CHECK: Final[int]
SQLITE_CONSTRAINT_COMMITHOOK: Final[int]
SQLITE_CONSTRAINT_FOREIGNKEY: Final[int]
SQLITE_CONSTRAINT_FUNCTION: Final[int]
SQLITE_CONSTRAINT_NOTNULL: Final[int]
SQLITE_CONSTRAINT_PINNED: Final[int]
SQLITE_CONSTRAINT_PRIMARYKEY: Final[int]
SQLITE_CONSTRAINT_ROWID: Final[int]
SQLITE_CONSTRAINT_TRIGGER: Final[int]
SQLITE_CONSTRAINT_UNIQUE: Final[int]
SQLITE_CONSTRAINT_VTAB: Final[int]
SQLITE_CORRUPT: Final[int]
SQLITE_CORRUPT_INDEX: Final[int]
SQLITE_CORRUPT_SEQUENCE: Final[int]
SQLITE_CORRUPT_VTAB: Final[int]
SQLITE_EMPTY: Final[int]
SQLITE_ERROR: Final[int]
SQLITE_ERROR_MISSING_COLLSEQ: Final[int]
SQLITE_ERROR_RETRY: Final[int]
SQLITE_ERROR_SNAPSHOT: Final[int]
SQLITE_FORMAT: Final[int]
SQLITE_FULL: Final[int]
SQLITE_INTERNAL: Final[int]
SQLITE_INTERRUPT: Final[int]
SQLITE_IOERR: Final[int]
SQLITE_IOERR_ACCESS: Final[int]
SQLITE_IOERR_AUTH: Final[int]
SQLITE_IOERR_BEGIN_ATOMIC: Final[int]
SQLITE_IOERR_BLOCKED: Final[int]
SQLITE_IOERR_CHECKRESERVEDLOCK: Final[int]
SQLITE_IOERR_CLOSE: Final[int]
SQLITE_IOERR_COMMIT_ATOMIC: Final[int]
SQLITE_IOERR_CONVPATH: Final[int]
SQLITE_IOERR_CORRUPTFS: Final[int]
SQLITE_IOERR_DATA: Final[int]
SQLITE_IOERR_DELETE: Final[int]
SQLITE_IOERR_DELETE_NOENT: Final[int]
SQLITE_IOERR_DIR_CLOSE: Final[int]
SQLITE_IOERR_DIR_FSYNC: Final[int]
SQLITE_IOERR_FSTAT: Final[int]
SQLITE_IOERR_FSYNC: Final[int]
SQLITE_IOERR_GETTEMPPATH: Final[int]
SQLITE_IOERR_LOCK: Final[int]
SQLITE_IOERR_MMAP: Final[int]
SQLITE_IOERR_NOMEM: Final[int]
SQLITE_IOERR_RDLOCK: Final[int]
SQLITE_IOERR_READ: Final[int]
SQLITE_IOERR_ROLLBACK_ATOMIC: Final[int]
SQLITE_IOERR_SEEK: Final[int]
SQLITE_IOERR_SHMLOCK: Final[int]
SQLITE_IOERR_SHMMAP: Final[int]
SQLITE_IOERR_SHMOPEN: Final[int]
SQLITE_IOERR_SHMSIZE: Final[int]
SQLITE_IOERR_SHORT_READ: Final[int]
SQLITE_IOERR_TRUNCATE: Final[int]
SQLITE_IOERR_UNLOCK: Final[int]
SQLITE_IOERR_VNODE: Final[int]
SQLITE_IOERR_WRITE: Final[int]
SQLITE_LIMIT_ATTACHED: Final[int]
SQLITE_LIMIT_COLUMN: Final[int]
SQLITE_LIMIT_COMPOUND_SELECT: Final[int]
SQLITE_LIMIT_EXPR_DEPTH: Final[int]
SQLITE_LIMIT_FUNCTION_ARG: Final[int]
SQLITE_LIMIT_LENGTH: Final[int]
SQLITE_LIMIT_LIKE_PATTERN_LENGTH: Final[int]
SQLITE_LIMIT_SQL_LENGTH: Final[int]
SQLITE_LIMIT_TRIGGER_DEPTH: Final[int]
SQLITE_LIMIT_VARIABLE_NUMBER: Final[int]
SQLITE_LIMIT_VDBE_OP: Final[int]
SQLITE_LIMIT_WORKER_THREADS: Final[int]
SQLITE_LOCKED: Final[int]
SQLITE_LOCKED_SHAREDCACHE: Final[int]
SQLITE_LOCKED_VTAB: Final[int]
SQLITE_MISMATCH: Final[int]
SQLITE_MISUSE: Final[int]
SQLITE_NOLFS: Final[int]
SQLITE_NOMEM: Final[int]
SQLITE_NOTADB: Final[int]
SQLITE_NOTFOUND: Final[int]
SQLITE_NOTICE: Final[int]
SQLITE_NOTICE_RECOVER_ROLLBACK: Final[int]
SQLITE_NOTICE_RECOVER_WAL: Final[int]
SQLITE_OK_LOAD_PERMANENTLY: Final[int]
SQLITE_OK_SYMLINK: Final[int]
SQLITE_PERM: Final[int]
SQLITE_PROTOCOL: Final[int]
SQLITE_RANGE: Final[int]
SQLITE_READONLY: Final[int]
SQLITE_READONLY_CANTINIT: Final[int]
SQLITE_READONLY_CANTLOCK: Final[int]
SQLITE_READONLY_DBMOVED: Final[int]
SQLITE_READONLY_DIRECTORY: Final[int]
SQLITE_READONLY_RECOVERY: Final[int]
SQLITE_READONLY_ROLLBACK: Final[int]
SQLITE_ROW: Final[int]
SQLITE_SCHEMA: Final[int]
SQLITE_TOOBIG: Final[int]
SQLITE_WARNING: Final[int]
SQLITE_WARNING_AUTOINDEX: Final[int]
threadsafety: Final[int]
# Can take or return anything depending on what's in the registry.
@overload
def adapt(obj: Any, proto: Any, /) -> Any: ...
@overload
def adapt(obj: Any, proto: Any, alt: _T, /) -> Any | _T: ...
def complete_statement(statement: str) -> bool: ...
if sys.version_info >= (3, 12):
@overload
def connect(
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None = "DEFERRED",
check_same_thread: bool = True,
cached_statements: int = 128,
uri: bool = False,
*,
autocommit: bool = ...,
) -> Connection: ...
@overload
def connect(
database: StrOrBytesPath,
timeout: float,
detect_types: int,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None,
check_same_thread: bool,
factory: type[_ConnectionT],
cached_statements: int = 128,
uri: bool = False,
*,
autocommit: bool = ...,
) -> _ConnectionT: ...
@overload
def connect(
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None = "DEFERRED",
check_same_thread: bool = True,
*,
factory: type[_ConnectionT],
cached_statements: int = 128,
uri: bool = False,
autocommit: bool = ...,
) -> _ConnectionT: ...
else:
@overload
def connect(
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None = "DEFERRED",
check_same_thread: bool = True,
cached_statements: int = 128,
uri: bool = False,
) -> Connection: ...
@overload
def connect(
database: StrOrBytesPath,
timeout: float,
detect_types: int,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None,
check_same_thread: bool,
factory: type[_ConnectionT],
cached_statements: int = 128,
uri: bool = False,
) -> _ConnectionT: ...
@overload
def connect(
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None = "DEFERRED",
check_same_thread: bool = True,
*,
factory: type[_ConnectionT],
cached_statements: int = 128,
uri: bool = False,
) -> _ConnectionT: ...
def enable_callback_tracebacks(enable: bool, /) -> None: ...
if sys.version_info < (3, 12):
# takes a pos-or-keyword argument because there is a C wrapper
def enable_shared_cache(do_enable: int) -> None: ...
if sys.version_info >= (3, 10):
def register_adapter(type: type[_T], adapter: _Adapter[_T], /) -> None: ...
def register_converter(typename: str, converter: _Converter, /) -> None: ...
else:
def register_adapter(type: type[_T], caster: _Adapter[_T], /) -> None: ...
def register_converter(name: str, converter: _Converter, /) -> None: ...
if sys.version_info < (3, 10):
OptimizedUnicode = str

View file

@ -0,0 +1,292 @@
import sys
from _typeshed import ReadableBuffer, StrOrBytesPath
from collections.abc import Callable
from ssl import (
SSLCertVerificationError as SSLCertVerificationError,
SSLContext,
SSLEOFError as SSLEOFError,
SSLError as SSLError,
SSLObject,
SSLSyscallError as SSLSyscallError,
SSLWantReadError as SSLWantReadError,
SSLWantWriteError as SSLWantWriteError,
SSLZeroReturnError as SSLZeroReturnError,
)
from typing import Any, Literal, TypedDict, final, overload
from typing_extensions import NotRequired, Self, TypeAlias
_PasswordType: TypeAlias = Callable[[], str | bytes | bytearray] | str | bytes | bytearray
_PCTRTT: TypeAlias = tuple[tuple[str, str], ...]
_PCTRTTT: TypeAlias = tuple[_PCTRTT, ...]
_PeerCertRetDictType: TypeAlias = dict[str, str | _PCTRTTT | _PCTRTT]
class _Cipher(TypedDict):
aead: bool
alg_bits: int
auth: str
description: str
digest: str | None
id: int
kea: str
name: str
protocol: str
strength_bits: int
symmetric: str
class _CertInfo(TypedDict):
subject: tuple[tuple[tuple[str, str], ...], ...]
issuer: tuple[tuple[tuple[str, str], ...], ...]
version: int
serialNumber: str
notBefore: str
notAfter: str
subjectAltName: NotRequired[tuple[tuple[str, str], ...] | None]
OCSP: NotRequired[tuple[str, ...] | None]
caIssuers: NotRequired[tuple[str, ...] | None]
crlDistributionPoints: NotRequired[tuple[str, ...] | None]
def RAND_add(string: str | ReadableBuffer, entropy: float, /) -> None: ...
def RAND_bytes(n: int, /) -> bytes: ...
if sys.version_info < (3, 12):
def RAND_pseudo_bytes(n: int, /) -> tuple[bytes, bool]: ...
if sys.version_info < (3, 10):
def RAND_egd(path: str) -> None: ...
def RAND_status() -> bool: ...
def get_default_verify_paths() -> tuple[str, str, str, str]: ...
if sys.platform == "win32":
_EnumRetType: TypeAlias = list[tuple[bytes, str, set[str] | bool]]
def enum_certificates(store_name: str) -> _EnumRetType: ...
def enum_crls(store_name: str) -> _EnumRetType: ...
def txt2obj(txt: str, name: bool = False) -> tuple[int, str, str, str]: ...
def nid2obj(nid: int, /) -> tuple[int, str, str, str]: ...
class _SSLContext:
check_hostname: bool
keylog_filename: str | None
maximum_version: int
minimum_version: int
num_tickets: int
options: int
post_handshake_auth: bool
protocol: int
if sys.version_info >= (3, 10):
security_level: int
sni_callback: Callable[[SSLObject, str, SSLContext], None | int] | None
verify_flags: int
verify_mode: int
def __new__(cls, protocol: int, /) -> Self: ...
def cert_store_stats(self) -> dict[str, int]: ...
@overload
def get_ca_certs(self, binary_form: Literal[False] = False) -> list[_PeerCertRetDictType]: ...
@overload
def get_ca_certs(self, binary_form: Literal[True]) -> list[bytes]: ...
@overload
def get_ca_certs(self, binary_form: bool = False) -> Any: ...
def get_ciphers(self) -> list[_Cipher]: ...
def load_cert_chain(
self, certfile: StrOrBytesPath, keyfile: StrOrBytesPath | None = None, password: _PasswordType | None = None
) -> None: ...
def load_dh_params(self, path: str, /) -> None: ...
def load_verify_locations(
self,
cafile: StrOrBytesPath | None = None,
capath: StrOrBytesPath | None = None,
cadata: str | ReadableBuffer | None = None,
) -> None: ...
def session_stats(self) -> dict[str, int]: ...
def set_ciphers(self, cipherlist: str, /) -> None: ...
def set_default_verify_paths(self) -> None: ...
def set_ecdh_curve(self, name: str, /) -> None: ...
if sys.version_info >= (3, 13):
def set_psk_client_callback(self, callback: Callable[[str | None], tuple[str | None, bytes]] | None) -> None: ...
def set_psk_server_callback(
self, callback: Callable[[str | None], tuple[str | None, bytes]] | None, identity_hint: str | None = None
) -> None: ...
@final
class MemoryBIO:
eof: bool
pending: int
def __new__(self) -> Self: ...
def read(self, size: int = -1, /) -> bytes: ...
def write(self, b: ReadableBuffer, /) -> int: ...
def write_eof(self) -> None: ...
@final
class SSLSession:
@property
def has_ticket(self) -> bool: ...
@property
def id(self) -> bytes: ...
@property
def ticket_lifetime_hint(self) -> int: ...
@property
def time(self) -> int: ...
@property
def timeout(self) -> int: ...
# _ssl.Certificate is weird: it can't be instantiated or subclassed.
# Instances can only be created via methods of the private _ssl._SSLSocket class,
# for which the relevant method signatures are:
#
# class _SSLSocket:
# def get_unverified_chain(self) -> list[Certificate] | None: ...
# def get_verified_chain(self) -> list[Certificate] | None: ...
#
# You can find a _ssl._SSLSocket object as the _sslobj attribute of a ssl.SSLSocket object
if sys.version_info >= (3, 10):
@final
class Certificate:
def get_info(self) -> _CertInfo: ...
@overload
def public_bytes(self) -> str: ...
@overload
def public_bytes(self, format: Literal[1] = 1, /) -> str: ... # ENCODING_PEM
@overload
def public_bytes(self, format: Literal[2], /) -> bytes: ... # ENCODING_DER
@overload
def public_bytes(self, format: int, /) -> str | bytes: ...
if sys.version_info < (3, 12):
err_codes_to_names: dict[tuple[int, int], str]
err_names_to_codes: dict[str, tuple[int, int]]
lib_codes_to_names: dict[int, str]
_DEFAULT_CIPHERS: str
# SSL error numbers
SSL_ERROR_ZERO_RETURN: int
SSL_ERROR_WANT_READ: int
SSL_ERROR_WANT_WRITE: int
SSL_ERROR_WANT_X509_LOOKUP: int
SSL_ERROR_SYSCALL: int
SSL_ERROR_SSL: int
SSL_ERROR_WANT_CONNECT: int
SSL_ERROR_EOF: int
SSL_ERROR_INVALID_ERROR_CODE: int
# verify modes
CERT_NONE: int
CERT_OPTIONAL: int
CERT_REQUIRED: int
# verify flags
VERIFY_DEFAULT: int
VERIFY_CRL_CHECK_LEAF: int
VERIFY_CRL_CHECK_CHAIN: int
VERIFY_X509_STRICT: int
VERIFY_X509_TRUSTED_FIRST: int
if sys.version_info >= (3, 10):
VERIFY_ALLOW_PROXY_CERTS: int
VERIFY_X509_PARTIAL_CHAIN: int
# alert descriptions
ALERT_DESCRIPTION_CLOSE_NOTIFY: int
ALERT_DESCRIPTION_UNEXPECTED_MESSAGE: int
ALERT_DESCRIPTION_BAD_RECORD_MAC: int
ALERT_DESCRIPTION_RECORD_OVERFLOW: int
ALERT_DESCRIPTION_DECOMPRESSION_FAILURE: int
ALERT_DESCRIPTION_HANDSHAKE_FAILURE: int
ALERT_DESCRIPTION_BAD_CERTIFICATE: int
ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE: int
ALERT_DESCRIPTION_CERTIFICATE_REVOKED: int
ALERT_DESCRIPTION_CERTIFICATE_EXPIRED: int
ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN: int
ALERT_DESCRIPTION_ILLEGAL_PARAMETER: int
ALERT_DESCRIPTION_UNKNOWN_CA: int
ALERT_DESCRIPTION_ACCESS_DENIED: int
ALERT_DESCRIPTION_DECODE_ERROR: int
ALERT_DESCRIPTION_DECRYPT_ERROR: int
ALERT_DESCRIPTION_PROTOCOL_VERSION: int
ALERT_DESCRIPTION_INSUFFICIENT_SECURITY: int
ALERT_DESCRIPTION_INTERNAL_ERROR: int
ALERT_DESCRIPTION_USER_CANCELLED: int
ALERT_DESCRIPTION_NO_RENEGOTIATION: int
ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION: int
ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE: int
ALERT_DESCRIPTION_UNRECOGNIZED_NAME: int
ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE: int
ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE: int
ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY: int
# protocol versions
PROTOCOL_SSLv23: int
PROTOCOL_TLS: int
PROTOCOL_TLS_CLIENT: int
PROTOCOL_TLS_SERVER: int
PROTOCOL_TLSv1: int
PROTOCOL_TLSv1_1: int
PROTOCOL_TLSv1_2: int
# protocol options
OP_ALL: int
OP_NO_SSLv2: int
OP_NO_SSLv3: int
OP_NO_TLSv1: int
OP_NO_TLSv1_1: int
OP_NO_TLSv1_2: int
OP_NO_TLSv1_3: int
OP_CIPHER_SERVER_PREFERENCE: int
OP_SINGLE_DH_USE: int
OP_NO_TICKET: int
OP_SINGLE_ECDH_USE: int
OP_NO_COMPRESSION: int
OP_ENABLE_MIDDLEBOX_COMPAT: int
OP_NO_RENEGOTIATION: int
if sys.version_info >= (3, 11):
OP_IGNORE_UNEXPECTED_EOF: int
elif sys.version_info >= (3, 8) and sys.platform == "linux":
OP_IGNORE_UNEXPECTED_EOF: int
if sys.version_info >= (3, 12):
OP_LEGACY_SERVER_CONNECT: int
OP_ENABLE_KTLS: int
# host flags
HOSTFLAG_ALWAYS_CHECK_SUBJECT: int
HOSTFLAG_NEVER_CHECK_SUBJECT: int
HOSTFLAG_NO_WILDCARDS: int
HOSTFLAG_NO_PARTIAL_WILDCARDS: int
HOSTFLAG_MULTI_LABEL_WILDCARDS: int
HOSTFLAG_SINGLE_LABEL_SUBDOMAINS: int
if sys.version_info >= (3, 10):
# certificate file types
# Typed as Literal so the overload on Certificate.public_bytes can work properly.
ENCODING_PEM: Literal[1]
ENCODING_DER: Literal[2]
# protocol versions
PROTO_MINIMUM_SUPPORTED: int
PROTO_MAXIMUM_SUPPORTED: int
PROTO_SSLv3: int
PROTO_TLSv1: int
PROTO_TLSv1_1: int
PROTO_TLSv1_2: int
PROTO_TLSv1_3: int
# feature support
HAS_SNI: bool
HAS_TLS_UNIQUE: bool
HAS_ECDH: bool
HAS_NPN: bool
if sys.version_info >= (3, 13):
HAS_PSK: bool
HAS_ALPN: bool
HAS_SSLv2: bool
HAS_SSLv3: bool
HAS_TLSv1: bool
HAS_TLSv1_1: bool
HAS_TLSv1_2: bool
HAS_TLSv1_3: bool
# version info
OPENSSL_VERSION_NUMBER: int
OPENSSL_VERSION_INFO: tuple[int, int, int, int, int]
OPENSSL_VERSION: str
_OPENSSL_API_VERSION: tuple[int, int, int, int, int]

View file

@ -1,37 +1,10 @@
import sys
from collections.abc import Callable
from typing import Any, Generic, TypeVar, final, overload
from typing_extensions import Self
if sys.version_info >= (3, 9):
from types import GenericAlias
from typing import Any, TypeVar, overload
from weakref import CallableProxyType as CallableProxyType, ProxyType as ProxyType, ReferenceType as ReferenceType, ref as ref
_C = TypeVar("_C", bound=Callable[..., Any])
_T = TypeVar("_T")
@final
class CallableProxyType(Generic[_C]): # "weakcallableproxy"
def __eq__(self, value: object, /) -> bool: ...
def __getattr__(self, attr: str) -> Any: ...
__call__: _C
@final
class ProxyType(Generic[_T]): # "weakproxy"
def __eq__(self, value: object, /) -> bool: ...
def __getattr__(self, attr: str) -> Any: ...
class ReferenceType(Generic[_T]):
__callback__: Callable[[Self], Any]
def __new__(cls, o: _T, callback: Callable[[Self], Any] | None = ..., /) -> Self: ...
def __init__(self, o: _T, callback: Callable[[Self], Any] | None = ..., /) -> None: ...
def __call__(self) -> _T | None: ...
def __eq__(self, value: object, /) -> bool: ...
def __hash__(self) -> int: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
ref = ReferenceType
def getweakrefcount(object: Any, /) -> int: ...
def getweakrefs(object: Any, /) -> list[Any]: ...

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,11 @@
import ssl
import sys
from _asyncio import (
_get_running_loop as _get_running_loop,
_set_running_loop as _set_running_loop,
get_event_loop as get_event_loop,
get_running_loop as get_running_loop,
)
from _typeshed import FileDescriptorLike, ReadableBuffer, StrPath, Unused, WriteableBuffer
from abc import ABCMeta, abstractmethod
from collections.abc import Callable, Sequence
@ -632,7 +638,6 @@ class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy, metaclass=ABCMeta):
def get_event_loop_policy() -> AbstractEventLoopPolicy: ...
def set_event_loop_policy(policy: AbstractEventLoopPolicy | None) -> None: ...
def get_event_loop() -> AbstractEventLoop: ...
def set_event_loop(loop: AbstractEventLoop | None) -> None: ...
def new_event_loop() -> AbstractEventLoop: ...
@ -646,7 +651,3 @@ if sys.version_info < (3, 14):
else:
def get_child_watcher() -> AbstractChildWatcher: ...
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...
def _set_running_loop(loop: AbstractEventLoop | None, /) -> None: ...
def _get_running_loop() -> AbstractEventLoop: ...
def get_running_loop() -> AbstractEventLoop: ...

View file

@ -1,15 +1,10 @@
import sys
from collections.abc import Awaitable, Callable, Generator, Iterable
from _asyncio import Future as Future
from concurrent.futures._base import Future as _ConcurrentFuture
from contextvars import Context
from typing import Any, Literal, TypeVar
from typing_extensions import Self, TypeIs
from typing import Any, TypeVar
from typing_extensions import TypeIs
from .events import AbstractEventLoop
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = ("Future", "wrap_future", "isfuture")
_T = TypeVar("_T")
@ -18,40 +13,4 @@ _T = TypeVar("_T")
# but it leads to circular import error in pytype tool.
# That's why the import order is reversed.
def isfuture(obj: object) -> TypeIs[Future[Any]]: ...
class Future(Awaitable[_T], Iterable[_T]):
_state: str
@property
def _exception(self) -> BaseException | None: ...
_blocking: bool
@property
def _log_traceback(self) -> bool: ...
@_log_traceback.setter
def _log_traceback(self, val: Literal[False]) -> None: ...
_asyncio_future_blocking: bool # is a part of duck-typing contract for `Future`
def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ...
def __del__(self) -> None: ...
def get_loop(self) -> AbstractEventLoop: ...
@property
def _callbacks(self) -> list[tuple[Callable[[Self], Any], Context]]: ...
def add_done_callback(self, fn: Callable[[Self], object], /, *, context: Context | None = None) -> None: ...
if sys.version_info >= (3, 9):
def cancel(self, msg: Any | None = None) -> bool: ...
else:
def cancel(self) -> bool: ...
def cancelled(self) -> bool: ...
def done(self) -> bool: ...
def result(self) -> _T: ...
def exception(self) -> BaseException | None: ...
def remove_done_callback(self, fn: Callable[[Self], object], /) -> int: ...
def set_result(self, result: _T, /) -> None: ...
def set_exception(self, exception: type | BaseException, /) -> None: ...
def __iter__(self) -> Generator[Any, None, _T]: ...
def __await__(self) -> Generator[Any, None, _T]: ...
@property
def _loop(self) -> AbstractEventLoop: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def wrap_future(future: _ConcurrentFuture[_T] | Future[_T], *, loop: AbstractEventLoop | None = None) -> Future[_T]: ...

View file

@ -1,16 +1,20 @@
import concurrent.futures
import sys
from _asyncio import (
Task as Task,
_enter_task as _enter_task,
_leave_task as _leave_task,
_register_task as _register_task,
_unregister_task as _unregister_task,
)
from collections.abc import Awaitable, Coroutine, Generator, Iterable, Iterator
from types import FrameType
from typing import Any, Literal, Protocol, TextIO, TypeVar, overload
from typing import Any, Literal, Protocol, TypeVar, overload
from typing_extensions import TypeAlias
from . import _CoroutineLike
from .events import AbstractEventLoop
from .futures import Future
if sys.version_info >= (3, 9):
from types import GenericAlias
if sys.version_info >= (3, 11):
from contextvars import Context
@ -400,58 +404,6 @@ elif sys.version_info >= (3, 9):
else:
_TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Awaitable[_T_co]
# mypy and pyright complain that a subclass of an invariant class shouldn't be covariant.
# While this is true in general, here it's sort-of okay to have a covariant subclass,
# since the only reason why `asyncio.Future` is invariant is the `set_result()` method,
# and `asyncio.Task.set_result()` always raises.
class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportInvalidTypeArguments]
if sys.version_info >= (3, 12):
def __init__(
self,
coro: _TaskCompatibleCoro[_T_co],
*,
loop: AbstractEventLoop = ...,
name: str | None = ...,
context: Context | None = None,
eager_start: bool = False,
) -> None: ...
elif sys.version_info >= (3, 11):
def __init__(
self,
coro: _TaskCompatibleCoro[_T_co],
*,
loop: AbstractEventLoop = ...,
name: str | None = ...,
context: Context | None = None,
) -> None: ...
else:
def __init__(
self, coro: _TaskCompatibleCoro[_T_co], *, loop: AbstractEventLoop = ..., name: str | None = ...
) -> None: ...
if sys.version_info >= (3, 12):
def get_coro(self) -> _TaskCompatibleCoro[_T_co] | None: ...
else:
def get_coro(self) -> _TaskCompatibleCoro[_T_co]: ...
def get_name(self) -> str: ...
def set_name(self, value: object, /) -> None: ...
if sys.version_info >= (3, 12):
def get_context(self) -> Context: ...
def get_stack(self, *, limit: int | None = None) -> list[FrameType]: ...
def print_stack(self, *, limit: int | None = None, file: TextIO | None = None) -> None: ...
if sys.version_info >= (3, 11):
def cancelling(self) -> int: ...
def uncancel(self) -> int: ...
if sys.version_info < (3, 9):
@classmethod
def current_task(cls, loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
@classmethod
def all_tasks(cls, loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def all_tasks(loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...
if sys.version_info >= (3, 11):
@ -460,9 +412,10 @@ if sys.version_info >= (3, 11):
else:
def create_task(coro: _CoroutineLike[_T], *, name: str | None = None) -> Task[_T]: ...
def current_task(loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
def _enter_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...
def _leave_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...
if sys.version_info >= (3, 12):
from _asyncio import current_task as current_task
else:
def current_task(loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
if sys.version_info >= (3, 12):
_TaskT_co = TypeVar("_TaskT_co", bound=Task[Any], covariant=True)
@ -499,6 +452,3 @@ if sys.version_info >= (3, 12):
name: str | None = None,
context: Context | None = None,
) -> Task[_T_co]: ...
def _register_task(task: Task[Any]) -> None: ...
def _unregister_task(task: Task[Any]) -> None: ...

View file

@ -589,7 +589,10 @@ class str(Sequence[str]):
def __contains__(self, key: str, /) -> bool: ... # type: ignore[override]
def __eq__(self, value: object, /) -> bool: ...
def __ge__(self, value: str, /) -> bool: ...
def __getitem__(self, key: SupportsIndex | slice, /) -> str: ...
@overload
def __getitem__(self: LiteralString, key: SupportsIndex | slice, /) -> LiteralString: ...
@overload
def __getitem__(self, key: SupportsIndex | slice, /) -> str: ... # type: ignore[misc]
def __gt__(self, value: str, /) -> bool: ...
def __hash__(self) -> int: ...
@overload
@ -831,7 +834,7 @@ _IntegerFormats: TypeAlias = Literal[
]
@final
class memoryview(Sequence[_I]):
class memoryview(Generic[_I]):
@property
def format(self) -> str: ...
@property
@ -1205,7 +1208,7 @@ class frozenset(AbstractSet[_T_co]):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
class enumerate(Iterator[tuple[int, _T]]):
def __new__(cls, iterable: Iterable[_T], start: int = ...) -> Self: ...
def __new__(cls, iterable: Iterable[_T], start: int = 0) -> Self: ...
def __iter__(self) -> Self: ...
def __next__(self) -> tuple[int, _T]: ...
if sys.version_info >= (3, 9):

View file

@ -131,7 +131,7 @@ class BZ2File(BaseStream, IO[bytes]):
@final
class BZ2Compressor:
def __init__(self, compresslevel: int = ...) -> None: ...
def __init__(self, compresslevel: int = 9) -> None: ...
def compress(self, data: ReadableBuffer, /) -> bytes: ...
def flush(self) -> bytes: ...

View file

@ -12,7 +12,11 @@ class InteractiveInterpreter:
def __init__(self, locals: Mapping[str, Any] | None = None) -> None: ...
def runsource(self, source: str, filename: str = "<input>", symbol: str = "single") -> bool: ...
def runcode(self, code: CodeType) -> None: ...
def showsyntaxerror(self, filename: str | None = None) -> None: ...
if sys.version_info >= (3, 13):
def showsyntaxerror(self, filename: str | None = None, *, source: str = "") -> None: ...
else:
def showsyntaxerror(self, filename: str | None = None) -> None: ...
def showtraceback(self) -> None: ...
def write(self, data: str) -> None: ...

View file

@ -17,7 +17,6 @@ if sys.version_info >= (3, 10):
Mapping,
MutableMapping,
MutableSequence,
Reversible,
Sequence,
ValuesView,
)
@ -331,13 +330,13 @@ class Counter(dict[_T, int], Generic[_T]):
# The pure-Python implementations of the "views" classes
# These are exposed at runtime in `collections/__init__.py`
class _OrderedDictKeysView(KeysView[_KT_co], Reversible[_KT_co]):
class _OrderedDictKeysView(KeysView[_KT_co]):
def __reversed__(self) -> Iterator[_KT_co]: ...
class _OrderedDictItemsView(ItemsView[_KT_co, _VT_co], Reversible[tuple[_KT_co, _VT_co]]):
class _OrderedDictItemsView(ItemsView[_KT_co, _VT_co]):
def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
class _OrderedDictValuesView(ValuesView[_VT_co], Reversible[_VT_co]):
class _OrderedDictValuesView(ValuesView[_VT_co]):
def __reversed__(self) -> Iterator[_VT_co]: ...
# The C implementations of the "views" classes
@ -345,18 +344,18 @@ class _OrderedDictValuesView(ValuesView[_VT_co], Reversible[_VT_co]):
# but they are not exposed anywhere)
# pyright doesn't have a specific error code for subclassing error!
@final
class _odict_keys(dict_keys[_KT_co, _VT_co], Reversible[_KT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
class _odict_keys(dict_keys[_KT_co, _VT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
def __reversed__(self) -> Iterator[_KT_co]: ...
@final
class _odict_items(dict_items[_KT_co, _VT_co], Reversible[tuple[_KT_co, _VT_co]]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
class _odict_items(dict_items[_KT_co, _VT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
@final
class _odict_values(dict_values[_KT_co, _VT_co], Reversible[_VT_co], Generic[_KT_co, _VT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
class _odict_values(dict_values[_KT_co, _VT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
def __reversed__(self) -> Iterator[_VT_co]: ...
class OrderedDict(dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
class OrderedDict(dict[_KT, _VT]):
def popitem(self, last: bool = True) -> tuple[_KT, _VT]: ...
def move_to_end(self, key: _KT, last: bool = True) -> None: ...
def copy(self) -> Self: ...

View file

@ -19,8 +19,9 @@ _global_shutdown: bool
class _ThreadWakeup:
_closed: bool
_reader: Connection
_writer: Connection
# Any: Unused send and recv methods
_reader: Connection[Any, Any]
_writer: Connection[Any, Any]
def close(self) -> None: ...
def wakeup(self) -> None: ...
def clear(self) -> None: ...

View file

@ -143,13 +143,15 @@ class _RedirectStream(AbstractContextManager[_T_io, None]):
class redirect_stdout(_RedirectStream[_T_io]): ...
class redirect_stderr(_RedirectStream[_T_io]): ...
# In reality this is a subclass of `AbstractContextManager`;
# see #7961 for why we don't do that in the stub
class ExitStack(Generic[_ExitT_co], metaclass=abc.ABCMeta):
class _BaseExitStack(Generic[_ExitT_co]):
def enter_context(self, cm: AbstractContextManager[_T, _ExitT_co]) -> _T: ...
def push(self, exit: _CM_EF) -> _CM_EF: ...
def callback(self, callback: Callable[_P, _T], /, *args: _P.args, **kwds: _P.kwargs) -> Callable[_P, _T]: ...
def pop_all(self) -> Self: ...
# In reality this is a subclass of `AbstractContextManager`;
# see #7961 for why we don't do that in the stub
class ExitStack(_BaseExitStack[_ExitT_co], metaclass=abc.ABCMeta):
def close(self) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(
@ -163,16 +165,12 @@ _ACM_EF = TypeVar("_ACM_EF", bound=AbstractAsyncContextManager[Any, Any] | _Exit
# In reality this is a subclass of `AbstractAsyncContextManager`;
# see #7961 for why we don't do that in the stub
class AsyncExitStack(Generic[_ExitT_co], metaclass=abc.ABCMeta):
def enter_context(self, cm: AbstractContextManager[_T, _ExitT_co]) -> _T: ...
class AsyncExitStack(_BaseExitStack[_ExitT_co], metaclass=abc.ABCMeta):
async def enter_async_context(self, cm: AbstractAsyncContextManager[_T, _ExitT_co]) -> _T: ...
def push(self, exit: _CM_EF) -> _CM_EF: ...
def push_async_exit(self, exit: _ACM_EF) -> _ACM_EF: ...
def callback(self, callback: Callable[_P, _T], /, *args: _P.args, **kwds: _P.kwargs) -> Callable[_P, _T]: ...
def push_async_callback(
self, callback: Callable[_P, Awaitable[_T]], /, *args: _P.args, **kwds: _P.kwargs
) -> Callable[_P, Awaitable[_T]]: ...
def pop_all(self) -> Self: ...
async def aclose(self) -> None: ...
async def __aenter__(self) -> Self: ...
async def __aexit__(

View file

@ -1,12 +1,10 @@
import sys
# actually csv.Dialect is a different class to _csv.Dialect at runtime, but for typing purposes, they're identical
from _csv import (
QUOTE_ALL as QUOTE_ALL,
QUOTE_MINIMAL as QUOTE_MINIMAL,
QUOTE_NONE as QUOTE_NONE,
QUOTE_NONNUMERIC as QUOTE_NONNUMERIC,
Dialect as Dialect,
Dialect as _Dialect,
Error as Error,
__version__ as __version__,
_DialectLike,
@ -61,6 +59,9 @@ if sys.version_info < (3, 13):
_T = TypeVar("_T")
class Dialect(_Dialect):
def __init__(self) -> None: ...
class excel(Dialect): ...
class excel_tab(excel): ...
class unix_dialect(Dialect): ...

View file

@ -1,5 +1,5 @@
from _curses import *
from _curses import _CursesWindow as _CursesWindow
from _curses import window as window
from collections.abc import Callable
from typing import TypeVar
from typing_extensions import Concatenate, ParamSpec
@ -19,4 +19,9 @@ COLS: int
COLORS: int
COLOR_PAIRS: int
def wrapper(func: Callable[Concatenate[_CursesWindow, _P], _T], /, *arg: _P.args, **kwds: _P.kwargs) -> _T: ...
def wrapper(func: Callable[Concatenate[window, _P], _T], /, *arg: _P.args, **kwds: _P.kwargs) -> _T: ...
# typeshed used the name _CursesWindow for the underlying C class before
# it was mapped to the name 'window' in 3.8.
# Kept here as a legacy alias in case any third-party code is relying on it.
_CursesWindow = window

View file

@ -1,4 +1,4 @@
from _curses import _CursesWindow
from _curses import window
version: str
@ -9,14 +9,14 @@ class _Curses_Panel: # type is <class '_curses_panel.curses panel'> (note the s
def hidden(self) -> bool: ...
def hide(self) -> None: ...
def move(self, y: int, x: int) -> None: ...
def replace(self, win: _CursesWindow) -> None: ...
def replace(self, win: window) -> None: ...
def set_userptr(self, obj: object) -> None: ...
def show(self) -> None: ...
def top(self) -> None: ...
def userptr(self) -> object: ...
def window(self) -> _CursesWindow: ...
def window(self) -> window: ...
def bottom_panel() -> _Curses_Panel: ...
def new_panel(win: _CursesWindow, /) -> _Curses_Panel: ...
def new_panel(win: window, /) -> _Curses_Panel: ...
def top_panel() -> _Curses_Panel: ...
def update_panels() -> _Curses_Panel: ...

View file

@ -1,11 +1,11 @@
from _curses import _CursesWindow
from _curses import window
from collections.abc import Callable
def rectangle(win: _CursesWindow, uly: int, ulx: int, lry: int, lrx: int) -> None: ...
def rectangle(win: window, uly: int, ulx: int, lry: int, lrx: int) -> None: ...
class Textbox:
stripspaces: bool
def __init__(self, win: _CursesWindow, insert_mode: bool = False) -> None: ...
def __init__(self, win: window, insert_mode: bool = False) -> None: ...
def edit(self, validate: Callable[[int], int] | None = None) -> str: ...
def do_command(self, ch: str | int) -> None: ...
def gather(self) -> str: ...

View file

@ -1,2 +1,256 @@
from _decimal import *
from _decimal import __libmpdec_version__ as __libmpdec_version__, __version__ as __version__
import numbers
from _decimal import (
HAVE_CONTEXTVAR as HAVE_CONTEXTVAR,
HAVE_THREADS as HAVE_THREADS,
MAX_EMAX as MAX_EMAX,
MAX_PREC as MAX_PREC,
MIN_EMIN as MIN_EMIN,
MIN_ETINY as MIN_ETINY,
ROUND_05UP as ROUND_05UP,
ROUND_CEILING as ROUND_CEILING,
ROUND_DOWN as ROUND_DOWN,
ROUND_FLOOR as ROUND_FLOOR,
ROUND_HALF_DOWN as ROUND_HALF_DOWN,
ROUND_HALF_EVEN as ROUND_HALF_EVEN,
ROUND_HALF_UP as ROUND_HALF_UP,
ROUND_UP as ROUND_UP,
BasicContext as BasicContext,
DefaultContext as DefaultContext,
ExtendedContext as ExtendedContext,
__libmpdec_version__ as __libmpdec_version__,
__version__ as __version__,
getcontext as getcontext,
localcontext as localcontext,
setcontext as setcontext,
)
from collections.abc import Container, Sequence
from typing import Any, ClassVar, Literal, NamedTuple, overload
from typing_extensions import Self, TypeAlias
_Decimal: TypeAlias = Decimal | int
_DecimalNew: TypeAlias = Decimal | float | str | tuple[int, Sequence[int], int]
_ComparableNum: TypeAlias = Decimal | float | numbers.Rational
_TrapType: TypeAlias = type[DecimalException]
# At runtime, these classes are implemented in C as part of "_decimal".
# However, they consider themselves to live in "decimal", so we'll put them here.
class DecimalTuple(NamedTuple):
sign: int
digits: tuple[int, ...]
exponent: int | Literal["n", "N", "F"]
class DecimalException(ArithmeticError): ...
class Clamped(DecimalException): ...
class InvalidOperation(DecimalException): ...
class ConversionSyntax(InvalidOperation): ...
class DivisionByZero(DecimalException, ZeroDivisionError): ...
class DivisionImpossible(InvalidOperation): ...
class DivisionUndefined(InvalidOperation, ZeroDivisionError): ...
class Inexact(DecimalException): ...
class InvalidContext(InvalidOperation): ...
class Rounded(DecimalException): ...
class Subnormal(DecimalException): ...
class Overflow(Inexact, Rounded): ...
class Underflow(Inexact, Rounded, Subnormal): ...
class FloatOperation(DecimalException, TypeError): ...
class Decimal:
def __new__(cls, value: _DecimalNew = ..., context: Context | None = ...) -> Self: ...
@classmethod
def from_float(cls, f: float, /) -> Self: ...
def __bool__(self) -> bool: ...
def compare(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def __hash__(self) -> int: ...
def as_tuple(self) -> DecimalTuple: ...
def as_integer_ratio(self) -> tuple[int, int]: ...
def to_eng_string(self, context: Context | None = None) -> str: ...
def __abs__(self) -> Decimal: ...
def __add__(self, value: _Decimal, /) -> Decimal: ...
def __divmod__(self, value: _Decimal, /) -> tuple[Decimal, Decimal]: ...
def __eq__(self, value: object, /) -> bool: ...
def __floordiv__(self, value: _Decimal, /) -> Decimal: ...
def __ge__(self, value: _ComparableNum, /) -> bool: ...
def __gt__(self, value: _ComparableNum, /) -> bool: ...
def __le__(self, value: _ComparableNum, /) -> bool: ...
def __lt__(self, value: _ComparableNum, /) -> bool: ...
def __mod__(self, value: _Decimal, /) -> Decimal: ...
def __mul__(self, value: _Decimal, /) -> Decimal: ...
def __neg__(self) -> Decimal: ...
def __pos__(self) -> Decimal: ...
def __pow__(self, value: _Decimal, mod: _Decimal | None = None, /) -> Decimal: ...
def __radd__(self, value: _Decimal, /) -> Decimal: ...
def __rdivmod__(self, value: _Decimal, /) -> tuple[Decimal, Decimal]: ...
def __rfloordiv__(self, value: _Decimal, /) -> Decimal: ...
def __rmod__(self, value: _Decimal, /) -> Decimal: ...
def __rmul__(self, value: _Decimal, /) -> Decimal: ...
def __rsub__(self, value: _Decimal, /) -> Decimal: ...
def __rtruediv__(self, value: _Decimal, /) -> Decimal: ...
def __sub__(self, value: _Decimal, /) -> Decimal: ...
def __truediv__(self, value: _Decimal, /) -> Decimal: ...
def remainder_near(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def __float__(self) -> float: ...
def __int__(self) -> int: ...
def __trunc__(self) -> int: ...
@property
def real(self) -> Decimal: ...
@property
def imag(self) -> Decimal: ...
def conjugate(self) -> Decimal: ...
def __complex__(self) -> complex: ...
@overload
def __round__(self) -> int: ...
@overload
def __round__(self, ndigits: int, /) -> Decimal: ...
def __floor__(self) -> int: ...
def __ceil__(self) -> int: ...
def fma(self, other: _Decimal, third: _Decimal, context: Context | None = None) -> Decimal: ...
def __rpow__(self, value: _Decimal, mod: Context | None = None, /) -> Decimal: ...
def normalize(self, context: Context | None = None) -> Decimal: ...
def quantize(self, exp: _Decimal, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
def same_quantum(self, other: _Decimal, context: Context | None = None) -> bool: ...
def to_integral_exact(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
def to_integral_value(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
def to_integral(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
def sqrt(self, context: Context | None = None) -> Decimal: ...
def max(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def min(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def adjusted(self) -> int: ...
def canonical(self) -> Decimal: ...
def compare_signal(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def compare_total(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def compare_total_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def copy_abs(self) -> Decimal: ...
def copy_negate(self) -> Decimal: ...
def copy_sign(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def exp(self, context: Context | None = None) -> Decimal: ...
def is_canonical(self) -> bool: ...
def is_finite(self) -> bool: ...
def is_infinite(self) -> bool: ...
def is_nan(self) -> bool: ...
def is_normal(self, context: Context | None = None) -> bool: ...
def is_qnan(self) -> bool: ...
def is_signed(self) -> bool: ...
def is_snan(self) -> bool: ...
def is_subnormal(self, context: Context | None = None) -> bool: ...
def is_zero(self) -> bool: ...
def ln(self, context: Context | None = None) -> Decimal: ...
def log10(self, context: Context | None = None) -> Decimal: ...
def logb(self, context: Context | None = None) -> Decimal: ...
def logical_and(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def logical_invert(self, context: Context | None = None) -> Decimal: ...
def logical_or(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def logical_xor(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def max_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def min_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def next_minus(self, context: Context | None = None) -> Decimal: ...
def next_plus(self, context: Context | None = None) -> Decimal: ...
def next_toward(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def number_class(self, context: Context | None = None) -> str: ...
def radix(self) -> Decimal: ...
def rotate(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def scaleb(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def shift(self, other: _Decimal, context: Context | None = None) -> 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: ...
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.
# Type checkers either ignore it or misinterpret it
# if you add a `def __delattr__(self, name: str, /) -> NoReturn` method to the stub
prec: int
rounding: str
Emin: int
Emax: int
capitals: int
clamp: int
traps: dict[_TrapType, bool]
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] = ...,
_ignored_flags: list[_TrapType] | None = ...,
) -> None: ...
def __reduce__(self) -> tuple[type[Self], tuple[Any, ...]]: ...
def clear_flags(self) -> None: ...
def clear_traps(self) -> None: ...
def copy(self) -> Context: ...
def __copy__(self) -> Context: ...
# see https://github.com/python/cpython/issues/94107
__hash__: ClassVar[None] # type: ignore[assignment]
def Etiny(self) -> int: ...
def Etop(self) -> int: ...
def create_decimal(self, num: _DecimalNew = "0", /) -> Decimal: ...
def create_decimal_from_float(self, f: float, /) -> Decimal: ...
def abs(self, x: _Decimal, /) -> Decimal: ...
def add(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def canonical(self, x: Decimal, /) -> Decimal: ...
def compare(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def compare_signal(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def compare_total(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def compare_total_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def copy_abs(self, x: _Decimal, /) -> Decimal: ...
def copy_decimal(self, x: _Decimal, /) -> Decimal: ...
def copy_negate(self, x: _Decimal, /) -> Decimal: ...
def copy_sign(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def divide(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def divide_int(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def divmod(self, x: _Decimal, y: _Decimal, /) -> tuple[Decimal, Decimal]: ...
def exp(self, x: _Decimal, /) -> Decimal: ...
def fma(self, x: _Decimal, y: _Decimal, z: _Decimal, /) -> Decimal: ...
def is_canonical(self, x: _Decimal, /) -> bool: ...
def is_finite(self, x: _Decimal, /) -> bool: ...
def is_infinite(self, x: _Decimal, /) -> bool: ...
def is_nan(self, x: _Decimal, /) -> bool: ...
def is_normal(self, x: _Decimal, /) -> bool: ...
def is_qnan(self, x: _Decimal, /) -> bool: ...
def is_signed(self, x: _Decimal, /) -> bool: ...
def is_snan(self, x: _Decimal, /) -> bool: ...
def is_subnormal(self, x: _Decimal, /) -> bool: ...
def is_zero(self, x: _Decimal, /) -> bool: ...
def ln(self, x: _Decimal, /) -> Decimal: ...
def log10(self, x: _Decimal, /) -> Decimal: ...
def logb(self, x: _Decimal, /) -> Decimal: ...
def logical_and(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def logical_invert(self, x: _Decimal, /) -> Decimal: ...
def logical_or(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def logical_xor(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def max(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def max_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def min(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def min_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def minus(self, x: _Decimal, /) -> Decimal: ...
def multiply(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def next_minus(self, x: _Decimal, /) -> Decimal: ...
def next_plus(self, x: _Decimal, /) -> Decimal: ...
def next_toward(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def normalize(self, x: _Decimal, /) -> Decimal: ...
def number_class(self, x: _Decimal, /) -> str: ...
def plus(self, x: _Decimal, /) -> Decimal: ...
def power(self, a: _Decimal, b: _Decimal, modulo: _Decimal | None = None) -> Decimal: ...
def quantize(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def radix(self) -> Decimal: ...
def remainder(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def remainder_near(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def rotate(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def same_quantum(self, x: _Decimal, y: _Decimal, /) -> bool: ...
def scaleb(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def shift(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def sqrt(self, x: _Decimal, /) -> Decimal: ...
def subtract(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
def to_eng_string(self, x: _Decimal, /) -> str: ...
def to_sci_string(self, x: _Decimal, /) -> str: ...
def to_integral_exact(self, x: _Decimal, /) -> Decimal: ...
def to_integral_value(self, x: _Decimal, /) -> Decimal: ...
def to_integral(self, x: _Decimal, /) -> Decimal: ...

View file

@ -1,11 +1,29 @@
from abc import ABCMeta, abstractmethod
from collections.abc import Callable
from email.errors import MessageDefect
from email.header import Header
from email.message import Message
from typing import Generic, Protocol, TypeVar, type_check_only
from typing_extensions import Self
class _PolicyBase:
_MessageT = TypeVar("_MessageT", bound=Message, default=Message)
@type_check_only
class _MessageFactory(Protocol[_MessageT]):
def __call__(self, policy: Policy[_MessageT]) -> _MessageT: ...
# Policy below is the only known direct subclass of _PolicyBase. We therefore
# assume that the __init__ arguments and attributes of _PolicyBase are
# the same as those of Policy.
class _PolicyBase(Generic[_MessageT]):
max_line_length: int | None
linesep: str
cte_type: str
raise_on_defect: bool
mangle_from_: bool
message_factory: _MessageFactory[_MessageT] | None
# Added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5
verify_generated_headers: bool
def __init__(
self,
*,
@ -14,7 +32,7 @@ class _PolicyBase:
cte_type: str = "8bit",
raise_on_defect: bool = False,
mangle_from_: bool = ..., # default depends on sub-class
message_factory: Callable[[Policy], Message] | None = None,
message_factory: _MessageFactory[_MessageT] | None = None,
# Added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5
verify_generated_headers: bool = True,
) -> None: ...
@ -26,24 +44,15 @@ class _PolicyBase:
cte_type: str = ...,
raise_on_defect: bool = ...,
mangle_from_: bool = ...,
message_factory: Callable[[Policy], Message] | None = ...,
message_factory: _MessageFactory[_MessageT] | None = ...,
# Added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5
verify_generated_headers: bool = ...,
) -> Self: ...
def __add__(self, other: Policy) -> Self: ...
class Policy(_PolicyBase, metaclass=ABCMeta):
max_line_length: int | None
linesep: str
cte_type: str
raise_on_defect: bool
mangle_from_: bool
message_factory: Callable[[Policy], Message] | None
# Added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5
verify_generated_headers: bool
def handle_defect(self, obj: Message, defect: MessageDefect) -> None: ...
def register_defect(self, obj: Message, defect: MessageDefect) -> None: ...
class Policy(_PolicyBase[_MessageT], metaclass=ABCMeta):
def handle_defect(self, obj: _MessageT, defect: MessageDefect) -> None: ...
def register_defect(self, obj: _MessageT, defect: MessageDefect) -> None: ...
def header_max_count(self, name: str) -> int | None: ...
@abstractmethod
def header_source_parse(self, sourcelines: list[str]) -> tuple[str, str]: ...
@ -56,11 +65,11 @@ class Policy(_PolicyBase, metaclass=ABCMeta):
@abstractmethod
def fold_binary(self, name: str, value: str) -> bytes: ...
class Compat32(Policy):
class Compat32(Policy[_MessageT]):
def header_source_parse(self, sourcelines: list[str]) -> tuple[str, str]: ...
def header_store_parse(self, name: str, value: str) -> tuple[str, str]: ...
def header_fetch_parse(self, name: str, value: str) -> str | Header: ... # type: ignore[override]
def fold(self, name: str, value: str) -> str: ...
def fold_binary(self, name: str, value: str) -> bytes: ...
compat32: Compat32
compat32: Compat32[Message]

View file

@ -5,19 +5,19 @@ from typing import Generic, TypeVar, overload
__all__ = ["FeedParser", "BytesFeedParser"]
_MessageT = TypeVar("_MessageT", bound=Message)
_MessageT = TypeVar("_MessageT", bound=Message, default=Message)
class FeedParser(Generic[_MessageT]):
@overload
def __init__(self: FeedParser[Message], _factory: None = None, *, policy: Policy = ...) -> None: ...
def __init__(self: FeedParser[Message], _factory: None = None, *, policy: Policy[Message] = ...) -> None: ...
@overload
def __init__(self, _factory: Callable[[], _MessageT], *, policy: Policy = ...) -> None: ...
def __init__(self, _factory: Callable[[], _MessageT], *, policy: Policy[_MessageT] = ...) -> None: ...
def feed(self, data: str) -> None: ...
def close(self) -> _MessageT: ...
class BytesFeedParser(FeedParser[_MessageT]):
@overload
def __init__(self: BytesFeedParser[Message], _factory: None = None, *, policy: Policy = ...) -> None: ...
def __init__(self: BytesFeedParser[Message], _factory: None = None, *, policy: Policy[Message] = ...) -> None: ...
@overload
def __init__(self, _factory: Callable[[], _MessageT], *, policy: Policy = ...) -> None: ...
def __init__(self, _factory: Callable[[], _MessageT], *, policy: Policy[_MessageT] = ...) -> None: ...
def feed(self, data: bytes | bytearray) -> None: ... # type: ignore[override]

View file

@ -1,34 +1,71 @@
from _typeshed import SupportsWrite
from email.message import Message
from email.policy import Policy
from typing import Any, Generic, TypeVar, overload
from typing_extensions import Self
__all__ = ["Generator", "DecodedGenerator", "BytesGenerator"]
class Generator:
def clone(self, fp: SupportsWrite[str]) -> Self: ...
def write(self, s: str) -> None: ...
# By default, generators do not have a message policy.
_MessageT = TypeVar("_MessageT", bound=Message, default=Any)
class Generator(Generic[_MessageT]):
maxheaderlen: int | None
policy: Policy[_MessageT] | None
@overload
def __init__(
self: Generator[Any], # The Policy of the message is used.
outfp: SupportsWrite[str],
mangle_from_: bool | None = None,
maxheaderlen: int | None = None,
*,
policy: None = None,
) -> None: ...
@overload
def __init__(
self,
outfp: SupportsWrite[str],
mangle_from_: bool | None = None,
maxheaderlen: int | None = None,
*,
policy: Policy | None = None,
policy: Policy[_MessageT],
) -> None: ...
def flatten(self, msg: Message, unixfrom: bool = False, linesep: str | None = None) -> None: ...
def write(self, s: str) -> None: ...
def flatten(self, msg: _MessageT, unixfrom: bool = False, linesep: str | None = None) -> None: ...
def clone(self, fp: SupportsWrite[str]) -> Self: ...
class BytesGenerator(Generator):
class BytesGenerator(Generator[_MessageT]):
@overload
def __init__(
self: BytesGenerator[Any], # The Policy of the message is used.
outfp: SupportsWrite[bytes],
mangle_from_: bool | None = None,
maxheaderlen: int | None = None,
*,
policy: None = None,
) -> None: ...
@overload
def __init__(
self,
outfp: SupportsWrite[bytes],
mangle_from_: bool | None = None,
maxheaderlen: int | None = None,
*,
policy: Policy | None = None,
policy: Policy[_MessageT],
) -> None: ...
class DecodedGenerator(Generator):
class DecodedGenerator(Generator[_MessageT]):
@overload
def __init__(
self: DecodedGenerator[Any], # The Policy of the message is used.
outfp: SupportsWrite[str],
mangle_from_: bool | None = None,
maxheaderlen: int | None = None,
fmt: str | None = None,
*,
policy: None = None,
) -> None: ...
@overload
def __init__(
self,
outfp: SupportsWrite[str],
@ -36,5 +73,5 @@ class DecodedGenerator(Generator):
maxheaderlen: int | None = None,
fmt: str | None = None,
*,
policy: Policy | None = None,
policy: Policy[_MessageT],
) -> None: ...

View file

@ -30,10 +30,13 @@ class _SupportsDecodeToPayload(Protocol):
def decode(self, encoding: str, errors: str, /) -> _PayloadType | _MultipartPayloadType: ...
class Message(Generic[_HeaderT, _HeaderParamT]):
policy: Policy # undocumented
# The policy attributes and arguments in this class and its subclasses
# would ideally use Policy[Self], but this is not possible.
policy: Policy[Any] # undocumented
preamble: str | None
epilogue: str | None
defects: list[MessageDefect]
def __init__(self, policy: Policy[Any] = ...) -> None: ...
def is_multipart(self) -> bool: ...
def set_unixfrom(self, unixfrom: str) -> None: ...
def get_unixfrom(self) -> str | None: ...
@ -126,8 +129,8 @@ class Message(Generic[_HeaderT, _HeaderParamT]):
def get_charsets(self, failobj: _T) -> list[str | _T]: ...
def walk(self) -> Generator[Self, None, None]: ...
def get_content_disposition(self) -> str | None: ...
def as_string(self, unixfrom: bool = False, maxheaderlen: int = 0, policy: Policy | None = None) -> str: ...
def as_bytes(self, unixfrom: bool = False, policy: Policy | None = None) -> bytes: ...
def as_string(self, unixfrom: bool = False, maxheaderlen: int = 0, policy: Policy[Any] | None = None) -> str: ...
def as_bytes(self, unixfrom: bool = False, policy: Policy[Any] | None = None) -> bytes: ...
def __bytes__(self) -> bytes: ...
def set_param(
self,
@ -139,13 +142,12 @@ class Message(Generic[_HeaderT, _HeaderParamT]):
language: str = "",
replace: bool = False,
) -> None: ...
def __init__(self, policy: Policy = ...) -> None: ...
# The following two methods are undocumented, but a source code comment states that they are public API
def set_raw(self, name: str, value: _HeaderParamT) -> None: ...
def raw_items(self) -> Iterator[tuple[str, _HeaderT]]: ...
class MIMEPart(Message[_HeaderRegistryT, _HeaderRegistryParamT]):
def __init__(self, policy: Policy | None = None) -> None: ...
def __init__(self, policy: Policy[Any] | None = None) -> None: ...
def get_body(self, preferencelist: Sequence[str] = ("related", "html", "plain")) -> MIMEPart[_HeaderRegistryT] | None: ...
def attach(self, payload: Self) -> None: ... # type: ignore[override]
# The attachments are created via type(self) in the attach method. It's theoretically
@ -163,7 +165,7 @@ class MIMEPart(Message[_HeaderRegistryT, _HeaderRegistryParamT]):
def add_attachment(self, *args: Any, content_manager: ContentManager | None = ..., **kw: Any) -> None: ...
def clear(self) -> None: ...
def clear_content(self) -> None: ...
def as_string(self, unixfrom: bool = False, maxheaderlen: int | None = None, policy: Policy | None = None) -> str: ...
def as_string(self, unixfrom: bool = False, maxheaderlen: int | None = None, policy: Policy[Any] | None = None) -> str: ...
def is_attachment(self) -> bool: ...
class EmailMessage(MIMEPart): ...

View file

@ -12,9 +12,9 @@ _MessageT = TypeVar("_MessageT", bound=Message, default=Message)
class Parser(Generic[_MessageT]):
@overload
def __init__(self: Parser[Message[str, str]], _class: None = None, *, policy: Policy = ...) -> None: ...
def __init__(self: Parser[Message[str, str]], _class: None = None, *, policy: Policy[Message[str, str]] = ...) -> None: ...
@overload
def __init__(self, _class: Callable[[], _MessageT], *, policy: Policy = ...) -> None: ...
def __init__(self, _class: Callable[[], _MessageT], *, policy: Policy[_MessageT] = ...) -> None: ...
def parse(self, fp: SupportsRead[str], headersonly: bool = False) -> _MessageT: ...
def parsestr(self, text: str, headersonly: bool = False) -> _MessageT: ...
@ -25,9 +25,11 @@ class HeaderParser(Parser[_MessageT]):
class BytesParser(Generic[_MessageT]):
parser: Parser[_MessageT]
@overload
def __init__(self: BytesParser[Message[str, str]], _class: None = None, *, policy: Policy = ...) -> None: ...
def __init__(
self: BytesParser[Message[str, str]], _class: None = None, *, policy: Policy[Message[str, str]] = ...
) -> None: ...
@overload
def __init__(self, _class: Callable[[], _MessageT], *, policy: Policy = ...) -> None: ...
def __init__(self, _class: Callable[[], _MessageT], *, policy: Policy[_MessageT] = ...) -> None: ...
def parse(self, fp: _WrappedBuffer, headersonly: bool = False) -> _MessageT: ...
def parsebytes(self, text: bytes | bytearray, headersonly: bool = False) -> _MessageT: ...

View file

@ -1,16 +1,34 @@
from collections.abc import Callable
from email._policybase import Compat32 as Compat32, Policy as Policy, compat32 as compat32
from email._policybase import Compat32 as Compat32, Policy as Policy, _MessageFactory, compat32 as compat32
from email.contentmanager import ContentManager
from email.message import Message
from typing import Any
from email.message import EmailMessage, Message
from typing import Any, TypeVar, overload
__all__ = ["Compat32", "compat32", "Policy", "EmailPolicy", "default", "strict", "SMTP", "HTTP"]
class EmailPolicy(Policy):
_MessageT = TypeVar("_MessageT", bound=Message, default=Message)
class EmailPolicy(Policy[_MessageT]):
utf8: bool
refold_source: str
header_factory: Callable[[str, Any], Any]
content_manager: ContentManager
@overload
def __init__(
self: EmailPolicy[EmailMessage],
*,
max_line_length: int | None = ...,
linesep: str = ...,
cte_type: str = ...,
raise_on_defect: bool = ...,
mangle_from_: bool = ...,
message_factory: None = None,
utf8: bool = ...,
refold_source: str = ...,
header_factory: Callable[[str, str], str] = ...,
content_manager: ContentManager = ...,
) -> None: ...
@overload
def __init__(
self,
*,
@ -19,7 +37,7 @@ class EmailPolicy(Policy):
cte_type: str = ...,
raise_on_defect: bool = ...,
mangle_from_: bool = ...,
message_factory: Callable[[Policy], Message] | None = ...,
message_factory: _MessageFactory[_MessageT] | None = ...,
utf8: bool = ...,
refold_source: str = ...,
header_factory: Callable[[str, str], str] = ...,
@ -31,8 +49,8 @@ class EmailPolicy(Policy):
def fold(self, name: str, value: str) -> Any: ...
def fold_binary(self, name: str, value: str) -> bytes: ...
default: EmailPolicy
SMTP: EmailPolicy
SMTPUTF8: EmailPolicy
HTTP: EmailPolicy
strict: EmailPolicy
default: EmailPolicy[EmailMessage]
SMTP: EmailPolicy[EmailMessage]
SMTPUTF8: EmailPolicy[EmailMessage]
HTTP: EmailPolicy[EmailMessage]
strict: EmailPolicy[EmailMessage]

View file

@ -316,13 +316,24 @@ else:
__rand__ = __and__
__rxor__ = __xor__
# subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto()
class auto(IntFlag):
class auto:
_value_: Any
@_magic_enum_attr
def value(self) -> Any: ...
def __new__(cls) -> Self: ...
# These don't exist, but auto is basically immediately replaced with
# either an int or a str depending on the type of the enum. StrEnum's auto
# shouldn't have these, but they're needed for int versions of auto (mostly the __or__).
# Ideally type checkers would special case auto enough to handle this,
# but until then this is a slightly inaccurate helping hand.
def __or__(self, other: int | Self) -> Self: ...
def __and__(self, other: int | Self) -> Self: ...
def __xor__(self, other: int | Self) -> Self: ...
__ror__ = __or__
__rand__ = __and__
__rxor__ = __xor__
if sys.version_info >= (3, 11):
def pickle_by_global_name(self: Enum, proto: int) -> str: ...
def pickle_by_enum_name(self: _EnumMemberT, proto: int) -> tuple[Callable[..., Any], tuple[type[_EnumMemberT], str]]: ...

View file

@ -1,12 +1,11 @@
from _typeshed import ReadableBuffer, SizedBuffer
from collections.abc import Callable
from hashlib import _Hash as _HashlibHash
from types import ModuleType
from typing import Any, AnyStr, overload
from typing import AnyStr, overload
from typing_extensions import TypeAlias
# TODO more precise type for object of hashlib
_Hash: TypeAlias = Any
_DigestMod: TypeAlias = str | Callable[[], _Hash] | ModuleType
_DigestMod: TypeAlias = str | Callable[[], _HashlibHash] | ModuleType
trans_5C: bytes
trans_36: bytes

View file

@ -34,6 +34,7 @@ __all__ = [
_DataType: TypeAlias = SupportsRead[bytes] | Iterable[ReadableBuffer] | ReadableBuffer
_T = TypeVar("_T")
_MessageT = TypeVar("_MessageT", bound=email.message.Message)
_HeaderValue: TypeAlias = ReadableBuffer | str | int
HTTP_PORT: int
HTTPS_PORT: int
@ -167,7 +168,7 @@ class HTTPConnection:
method: str,
url: str,
body: _DataType | str | None = None,
headers: Mapping[str, str] = {},
headers: Mapping[str, _HeaderValue] = {},
*,
encode_chunked: bool = False,
) -> None: ...
@ -180,7 +181,7 @@ class HTTPConnection:
def connect(self) -> None: ...
def close(self) -> None: ...
def putrequest(self, method: str, url: str, skip_host: bool = False, skip_accept_encoding: bool = False) -> None: ...
def putheader(self, header: str | bytes, *argument: str | bytes) -> None: ...
def putheader(self, header: str | bytes, *values: _HeaderValue) -> None: ...
def endheaders(self, message_body: _DataType | None = None, *, encode_chunked: bool = False) -> None: ...
def send(self, data: _DataType | str) -> None: ...

View file

@ -1,13 +1,26 @@
import abc
import builtins
import codecs
import sys
from _typeshed import FileDescriptorOrPath, ReadableBuffer, WriteableBuffer
from collections.abc import Callable, Iterable, Iterator
from os import _Opener
from types import TracebackType
from typing import IO, Any, BinaryIO, Final, Generic, Literal, Protocol, TextIO, TypeVar, overload, type_check_only
from typing_extensions import Self
from _io import (
DEFAULT_BUFFER_SIZE as DEFAULT_BUFFER_SIZE,
BlockingIOError as BlockingIOError,
BufferedRandom as BufferedRandom,
BufferedReader as BufferedReader,
BufferedRWPair as BufferedRWPair,
BufferedWriter as BufferedWriter,
BytesIO as BytesIO,
FileIO as FileIO,
IncrementalNewlineDecoder as IncrementalNewlineDecoder,
StringIO as StringIO,
TextIOWrapper as TextIOWrapper,
_BufferedIOBase,
_IOBase,
_RawIOBase,
_TextIOBase,
_WrappedBuffer as _WrappedBuffer, # used elsewhere in typeshed
open as open,
open_code as open_code,
)
from typing import Final
__all__ = [
"BlockingIOError",
@ -32,208 +45,16 @@ __all__ = [
]
if sys.version_info >= (3, 11):
from _io import text_encoding as text_encoding
__all__ += ["DEFAULT_BUFFER_SIZE", "IncrementalNewlineDecoder", "text_encoding"]
_T = TypeVar("_T")
DEFAULT_BUFFER_SIZE: Final = 8192
SEEK_SET: Final = 0
SEEK_CUR: Final = 1
SEEK_END: Final = 2
open = builtins.open
def open_code(path: str) -> IO[bytes]: ...
BlockingIOError = builtins.BlockingIOError
class UnsupportedOperation(OSError, ValueError): ...
class IOBase(metaclass=abc.ABCMeta):
def __iter__(self) -> Iterator[bytes]: ...
def __next__(self) -> bytes: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
def close(self) -> None: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def readable(self) -> bool: ...
read: Callable[..., Any]
def readlines(self, hint: int = -1, /) -> list[bytes]: ...
def seek(self, offset: int, whence: int = ..., /) -> int: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def truncate(self, size: int | None = ..., /) -> int: ...
def writable(self) -> bool: ...
write: Callable[..., Any]
def writelines(self, lines: Iterable[ReadableBuffer], /) -> None: ...
def readline(self, size: int | None = -1, /) -> bytes: ...
def __del__(self) -> None: ...
@property
def closed(self) -> bool: ...
def _checkClosed(self) -> None: ... # undocumented
class RawIOBase(IOBase):
def readall(self) -> bytes: ...
def readinto(self, buffer: WriteableBuffer, /) -> int | None: ...
def write(self, b: ReadableBuffer, /) -> int | None: ...
def read(self, size: int = -1, /) -> bytes | None: ...
class BufferedIOBase(IOBase):
def detach(self) -> RawIOBase: ...
def readinto(self, buffer: WriteableBuffer, /) -> int: ...
def write(self, buffer: ReadableBuffer, /) -> int: ...
def readinto1(self, buffer: WriteableBuffer, /) -> int: ...
def read(self, size: int | None = ..., /) -> bytes: ...
def read1(self, size: int = ..., /) -> bytes: ...
class FileIO(RawIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of writelines in the base classes
mode: str
# The type of "name" equals the argument passed in to the constructor,
# but that can make FileIO incompatible with other I/O types that assume
# "name" is a str. In the future, making FileIO generic might help.
name: Any
def __init__(
self, file: FileDescriptorOrPath, mode: str = ..., closefd: bool = ..., opener: _Opener | None = ...
) -> None: ...
@property
def closefd(self) -> bool: ...
def write(self, b: ReadableBuffer, /) -> int: ...
def read(self, size: int = -1, /) -> bytes: ...
def __enter__(self) -> Self: ...
class BytesIO(BufferedIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of methods in the base classes
def __init__(self, initial_bytes: ReadableBuffer = ...) -> None: ...
# BytesIO does not contain a "name" field. This workaround is necessary
# to allow BytesIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
name: Any
def __enter__(self) -> Self: ...
def getvalue(self) -> bytes: ...
def getbuffer(self) -> memoryview: ...
def read1(self, size: int | None = -1, /) -> bytes: ...
class BufferedReader(BufferedIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of methods in the base classes
raw: RawIOBase
def __enter__(self) -> Self: ...
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
def peek(self, size: int = 0, /) -> bytes: ...
class BufferedWriter(BufferedIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of writelines in the base classes
raw: RawIOBase
def __enter__(self) -> Self: ...
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
def write(self, buffer: ReadableBuffer, /) -> int: ...
class BufferedRandom(BufferedReader, BufferedWriter): # type: ignore[misc] # incompatible definitions of methods in the base classes
def __enter__(self) -> Self: ...
def seek(self, target: int, whence: int = 0, /) -> int: ... # stubtest needs this
class BufferedRWPair(BufferedIOBase):
def __init__(self, reader: RawIOBase, writer: RawIOBase, buffer_size: int = ...) -> None: ...
def peek(self, size: int = ..., /) -> bytes: ...
class TextIOBase(IOBase):
encoding: str
errors: str | None
newlines: str | tuple[str, ...] | None
def __iter__(self) -> Iterator[str]: ... # type: ignore[override]
def __next__(self) -> str: ... # type: ignore[override]
def detach(self) -> BinaryIO: ...
def write(self, s: str, /) -> int: ...
def writelines(self, lines: Iterable[str], /) -> None: ... # type: ignore[override]
def readline(self, size: int = ..., /) -> str: ... # type: ignore[override]
def readlines(self, hint: int = -1, /) -> list[str]: ... # type: ignore[override]
def read(self, size: int | None = ..., /) -> str: ...
@type_check_only
class _WrappedBuffer(Protocol):
# "name" is wrapped by TextIOWrapper. Its type is inconsistent between
# the various I/O types, see the comments on TextIOWrapper.name and
# TextIO.name.
@property
def name(self) -> Any: ...
@property
def closed(self) -> bool: ...
def read(self, size: int = ..., /) -> ReadableBuffer: ...
# Optional: def read1(self, size: int, /) -> ReadableBuffer: ...
def write(self, b: bytes, /) -> object: ...
def flush(self) -> object: ...
def close(self) -> object: ...
def seekable(self) -> bool: ...
def readable(self) -> bool: ...
def writable(self) -> bool: ...
def truncate(self, size: int, /) -> int: ...
def fileno(self) -> int: ...
def isatty(self) -> bool: ...
# Optional: Only needs to be present if seekable() returns True.
# def seek(self, offset: Literal[0], whence: Literal[2]) -> int: ...
# def tell(self) -> int: ...
_BufferT_co = TypeVar("_BufferT_co", bound=_WrappedBuffer, default=_WrappedBuffer, covariant=True)
class TextIOWrapper(TextIOBase, TextIO, Generic[_BufferT_co]): # type: ignore[misc] # incompatible definitions of write in the base classes
def __init__(
self,
buffer: _BufferT_co,
encoding: str | None = None,
errors: str | None = None,
newline: str | None = None,
line_buffering: bool = False,
write_through: bool = False,
) -> None: ...
# Equals the "buffer" argument passed in to the constructor.
@property
def buffer(self) -> _BufferT_co: ... # type: ignore[override]
@property
def closed(self) -> bool: ...
@property
def line_buffering(self) -> bool: ...
@property
def write_through(self) -> bool: ...
def reconfigure(
self,
*,
encoding: str | None = None,
errors: str | None = None,
newline: str | None = None,
line_buffering: bool | None = None,
write_through: bool | None = None,
) -> None: ...
# These are inherited from TextIOBase, but must exist in the stub to satisfy mypy.
def __enter__(self) -> Self: ...
def __iter__(self) -> Iterator[str]: ... # type: ignore[override]
def __next__(self) -> str: ... # type: ignore[override]
def writelines(self, lines: Iterable[str], /) -> None: ... # type: ignore[override]
def readline(self, size: int = -1, /) -> str: ... # type: ignore[override]
def readlines(self, hint: int = -1, /) -> list[str]: ... # type: ignore[override]
# Equals the "buffer" argument passed in to the constructor.
def detach(self) -> _BufferT_co: ... # type: ignore[override]
# TextIOWrapper's version of seek only supports a limited subset of
# operations.
def seek(self, cookie: int, whence: int = 0, /) -> int: ...
class StringIO(TextIOWrapper):
def __init__(self, initial_value: str | None = ..., newline: str | None = ...) -> None: ...
# StringIO does not contain a "name" field. This workaround is necessary
# to allow StringIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
name: Any
def getvalue(self) -> str: ...
class IncrementalNewlineDecoder(codecs.IncrementalDecoder):
def __init__(self, decoder: codecs.IncrementalDecoder | None, translate: bool, errors: str = ...) -> None: ...
def decode(self, input: ReadableBuffer | str, final: bool = False) -> str: ...
@property
def newlines(self) -> str | tuple[str, ...] | None: ...
def setstate(self, state: tuple[bytes, int], /) -> None: ...
if sys.version_info >= (3, 10):
@overload
def text_encoding(encoding: None, stacklevel: int = 2, /) -> Literal["locale", "utf-8"]: ...
@overload
def text_encoding(encoding: _T, stacklevel: int = 2, /) -> _T: ...
class IOBase(_IOBase, metaclass=abc.ABCMeta): ...
class RawIOBase(_RawIOBase, IOBase): ...
class BufferedIOBase(_BufferedIOBase, IOBase): ...
class TextIOBase(_TextIOBase, IOBase): ...

View file

@ -1,6 +1,6 @@
import sys
from collections.abc import Iterable, Iterator
from typing import Any, Final, Generic, Literal, SupportsInt, TypeVar, overload
from typing import Any, Final, Generic, Literal, TypeVar, overload
from typing_extensions import Self, TypeAlias
# Undocumented length constants
@ -31,7 +31,7 @@ class _IPAddressBase:
@property
def version(self) -> int: ...
class _BaseAddress(_IPAddressBase, SupportsInt):
class _BaseAddress(_IPAddressBase):
def __init__(self, address: object) -> None: ...
def __add__(self, other: int) -> Self: ...
def __hash__(self) -> int: ...

View file

@ -1,6 +1,6 @@
import sys
from _typeshed import ReadableBuffer, Unused
from collections.abc import Iterable, Iterator, Sized
from collections.abc import Iterator
from typing import Final, Literal, NoReturn, overload
from typing_extensions import Self
@ -30,7 +30,7 @@ if sys.platform != "win32":
PAGESIZE: int
class mmap(Iterable[int], Sized):
class mmap:
if sys.platform == "win32":
def __init__(self, fileno: int, length: int, tagname: str | None = ..., access: int = ..., offset: int = ...) -> None: ...
else:

View file

@ -1,9 +1,9 @@
import socket
import sys
import types
from _typeshed import ReadableBuffer
from _typeshed import Incomplete, ReadableBuffer
from collections.abc import Iterable
from typing import Any, SupportsIndex
from types import TracebackType
from typing import Any, Generic, SupportsIndex, TypeVar
from typing_extensions import Self, TypeAlias
__all__ = ["Client", "Listener", "Pipe", "wait"]
@ -11,7 +11,11 @@ __all__ = ["Client", "Listener", "Pipe", "wait"]
# https://docs.python.org/3/library/multiprocessing.html#address-formats
_Address: TypeAlias = str | tuple[str, int]
class _ConnectionBase:
# Defaulting to Any to avoid forcing generics on a lot of pre-existing code
_SendT = TypeVar("_SendT", contravariant=True, default=Any)
_RecvT = TypeVar("_RecvT", covariant=True, default=Any)
class _ConnectionBase(Generic[_SendT, _RecvT]):
def __init__(self, handle: SupportsIndex, readable: bool = True, writable: bool = True) -> None: ...
@property
def closed(self) -> bool: ... # undocumented
@ -22,27 +26,27 @@ class _ConnectionBase:
def fileno(self) -> int: ...
def close(self) -> None: ...
def send_bytes(self, buf: ReadableBuffer, offset: int = 0, size: int | None = None) -> None: ...
def send(self, obj: Any) -> None: ...
def send(self, obj: _SendT) -> None: ...
def recv_bytes(self, maxlength: int | None = None) -> bytes: ...
def recv_bytes_into(self, buf: Any, offset: int = 0) -> int: ...
def recv(self) -> Any: ...
def recv(self) -> _RecvT: ...
def poll(self, timeout: float | None = 0.0) -> bool: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
def __del__(self) -> None: ...
class Connection(_ConnectionBase): ...
class Connection(_ConnectionBase[_SendT, _RecvT]): ...
if sys.platform == "win32":
class PipeConnection(_ConnectionBase): ...
class PipeConnection(_ConnectionBase[_SendT, _RecvT]): ...
class Listener:
def __init__(
self, address: _Address | None = None, family: str | None = None, backlog: int = 1, authkey: bytes | None = None
) -> None: ...
def accept(self) -> Connection: ...
def accept(self) -> Connection[Incomplete, Incomplete]: ...
def close(self) -> None: ...
@property
def address(self) -> _Address: ...
@ -50,26 +54,30 @@ class Listener:
def last_accepted(self) -> _Address | None: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
# Any: send and recv methods unused
if sys.version_info >= (3, 12):
def deliver_challenge(connection: Connection, authkey: bytes, digest_name: str = "sha256") -> None: ...
def deliver_challenge(connection: Connection[Any, Any], authkey: bytes, digest_name: str = "sha256") -> None: ...
else:
def deliver_challenge(connection: Connection, authkey: bytes) -> None: ...
def deliver_challenge(connection: Connection[Any, Any], authkey: bytes) -> None: ...
def answer_challenge(connection: Connection, authkey: bytes) -> None: ...
def answer_challenge(connection: Connection[Any, Any], authkey: bytes) -> None: ...
def wait(
object_list: Iterable[Connection | socket.socket | int], timeout: float | None = None
) -> list[Connection | socket.socket | int]: ...
def Client(address: _Address, family: str | None = None, authkey: bytes | None = None) -> Connection: ...
object_list: Iterable[Connection[_SendT, _RecvT] | socket.socket | int], timeout: float | None = None
) -> list[Connection[_SendT, _RecvT] | socket.socket | int]: ...
def Client(address: _Address, family: str | None = None, authkey: bytes | None = None) -> Connection[Any, Any]: ...
# N.B. Keep this in sync with multiprocessing.context.BaseContext.Pipe.
# _ConnectionBase is the common base class of Connection and PipeConnection
# and can be used in cross-platform code.
#
# The two connections should have the same generic types but inverted (Connection[_T1, _T2], Connection[_T2, _T1]).
# However, TypeVars scoped entirely within a return annotation is unspecified in the spec.
if sys.platform != "win32":
def Pipe(duplex: bool = True) -> tuple[Connection, Connection]: ...
def Pipe(duplex: bool = True) -> tuple[Connection[Any, Any], Connection[Any, Any]]: ...
else:
def Pipe(duplex: bool = True) -> tuple[PipeConnection, PipeConnection]: ...
def Pipe(duplex: bool = True) -> tuple[PipeConnection[Any, Any], PipeConnection[Any, Any]]: ...

View file

@ -47,10 +47,13 @@ class BaseContext:
# N.B. Keep this in sync with multiprocessing.connection.Pipe.
# _ConnectionBase is the common base class of Connection and PipeConnection
# and can be used in cross-platform code.
#
# The two connections should have the same generic types but inverted (Connection[_T1, _T2], Connection[_T2, _T1]).
# However, TypeVars scoped entirely within a return annotation is unspecified in the spec.
if sys.platform != "win32":
def Pipe(self, duplex: bool = True) -> tuple[Connection, Connection]: ...
def Pipe(self, duplex: bool = True) -> tuple[Connection[Any, Any], Connection[Any, Any]]: ...
else:
def Pipe(self, duplex: bool = True) -> tuple[PipeConnection, PipeConnection]: ...
def Pipe(self, duplex: bool = True) -> tuple[PipeConnection[Any, Any], PipeConnection[Any, Any]]: ...
def Barrier(
self, parties: int, action: Callable[..., object] | None = None, timeout: float | None = None

View file

@ -1,7 +1,7 @@
import queue
import sys
import threading
from _typeshed import SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT
from _typeshed import Incomplete, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT
from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping, MutableSequence, Sequence
from types import TracebackType
from typing import Any, AnyStr, ClassVar, Generic, SupportsIndex, TypeVar, overload
@ -129,7 +129,9 @@ class Server:
self, registry: dict[str, tuple[Callable[..., Any], Any, Any, Any]], address: Any, authkey: bytes, serializer: str
) -> None: ...
def serve_forever(self) -> None: ...
def accept_connection(self, c: Connection, name: str) -> None: ...
def accept_connection(
self, c: Connection[tuple[str, str | None], tuple[str, str, Iterable[Incomplete], Mapping[str, Incomplete]]], name: str
) -> None: ...
class BaseManager:
if sys.version_info >= (3, 11):

View file

@ -35,8 +35,8 @@ if sys.platform == "win32":
handle: int, target_process: int | None = None, inheritable: bool = False, *, source_process: int | None = None
) -> int: ...
def steal_handle(source_pid: int, handle: int) -> int: ...
def send_handle(conn: connection.PipeConnection, handle: int, destination_pid: int) -> None: ...
def recv_handle(conn: connection.PipeConnection) -> int: ...
def send_handle(conn: connection.PipeConnection[DupHandle, Any], handle: int, destination_pid: int) -> None: ...
def recv_handle(conn: connection.PipeConnection[Any, DupHandle]) -> int: ...
class DupHandle:
def __init__(self, handle: int, access: int, pid: int | None = None) -> None: ...

View file

@ -1,5 +1,66 @@
import sys
from _operator import *
from _operator import (
abs as abs,
add as add,
and_ as and_,
concat as concat,
contains as contains,
countOf as countOf,
delitem as delitem,
eq as eq,
floordiv as floordiv,
ge as ge,
getitem as getitem,
gt as gt,
iadd as iadd,
iand as iand,
iconcat as iconcat,
ifloordiv as ifloordiv,
ilshift as ilshift,
imatmul as imatmul,
imod as imod,
imul as imul,
index as index,
indexOf as indexOf,
inv as inv,
invert as invert,
ior as ior,
ipow as ipow,
irshift as irshift,
is_ as is_,
is_not as is_not,
isub as isub,
itruediv as itruediv,
ixor as ixor,
le as le,
length_hint as length_hint,
lshift as lshift,
lt as lt,
matmul as matmul,
mod as mod,
mul as mul,
ne as ne,
neg as neg,
not_ as not_,
or_ as or_,
pos as pos,
pow as pow,
rshift as rshift,
setitem as setitem,
sub as sub,
truediv as truediv,
truth as truth,
xor as xor,
)
from _typeshed import SupportsGetItem
from typing import Any, Generic, TypeVar, final, overload
from typing_extensions import TypeVarTuple, Unpack
_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
_T1 = TypeVar("_T1")
_T2 = TypeVar("_T2")
_Ts = TypeVarTuple("_Ts")
__all__ = [
"abs",
@ -59,9 +120,13 @@ __all__ = [
]
if sys.version_info >= (3, 11):
from _operator import call as call
__all__ += ["call"]
if sys.version_info >= (3, 14):
from _operator import is_none as is_none, is_not_none as is_not_none
__all__ += ["is_none", "is_not_none"]
__lt__ = lt
@ -111,3 +176,40 @@ __itruediv__ = itruediv
__ixor__ = ixor
if sys.version_info >= (3, 11):
__call__ = call
# At runtime, these classes are implemented in C as part of the _operator module
# However, they consider themselves to live in the operator module, so we'll put
# them here.
@final
class attrgetter(Generic[_T_co]):
@overload
def __new__(cls, attr: str, /) -> attrgetter[Any]: ...
@overload
def __new__(cls, attr: str, attr2: str, /) -> attrgetter[tuple[Any, Any]]: ...
@overload
def __new__(cls, attr: str, attr2: str, attr3: str, /) -> attrgetter[tuple[Any, Any, Any]]: ...
@overload
def __new__(cls, attr: str, attr2: str, attr3: str, attr4: str, /) -> attrgetter[tuple[Any, Any, Any, Any]]: ...
@overload
def __new__(cls, attr: str, /, *attrs: str) -> attrgetter[tuple[Any, ...]]: ...
def __call__(self, obj: Any, /) -> _T_co: ...
@final
class itemgetter(Generic[_T_co]):
@overload
def __new__(cls, item: _T, /) -> itemgetter[_T]: ...
@overload
def __new__(cls, item1: _T1, item2: _T2, /, *items: Unpack[_Ts]) -> itemgetter[tuple[_T1, _T2, Unpack[_Ts]]]: ...
# __key: _KT_contra in SupportsGetItem seems to be causing variance issues, ie:
# TypeVar "_KT_contra@SupportsGetItem" is contravariant
# "tuple[int, int]" is incompatible with protocol "SupportsIndex"
# preventing [_T_co, ...] instead of [Any, ...]
#
# A suspected mypy issue prevents using [..., _T] instead of [..., Any] here.
# https://github.com/python/mypy/issues/14032
def __call__(self, obj: SupportsGetItem[Any, Any]) -> Any: ...
@final
class methodcaller:
def __init__(self, name: str, /, *args: Any, **kwargs: Any) -> None: ...
def __call__(self, obj: Any) -> Any: ...

View file

@ -23,8 +23,9 @@ from abc import abstractmethod
from builtins import OSError
from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping, Sequence
from contextlib import AbstractContextManager
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper as _TextIOWrapper
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
from subprocess import Popen
from types import TracebackType
from typing import (
IO,
Any,
@ -578,7 +579,7 @@ def fdopen(
newline: str | None = ...,
closefd: bool = ...,
opener: _Opener | None = ...,
) -> _TextIOWrapper: ...
) -> TextIOWrapper: ...
@overload
def fdopen(
fd: int,
@ -917,9 +918,25 @@ if sys.platform != "win32":
if sys.platform != "darwin" and sys.platform != "linux":
def plock(op: int, /) -> None: ...
class _wrap_close(_TextIOWrapper):
def __init__(self, stream: _TextIOWrapper, proc: Popen[str]) -> None: ...
def close(self) -> int | None: ... # type: ignore[override]
class _wrap_close:
def __init__(self, stream: TextIOWrapper, proc: Popen[str]) -> None: ...
def close(self) -> int | None: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
def __iter__(self) -> Iterator[str]: ...
# Methods below here don't exist directly on the _wrap_close object, but
# are copied from the wrapped TextIOWrapper object via __getattr__.
# The full set of TextIOWrapper methods are technically available this way,
# but undocumented. Only a subset are currently included here.
def read(self, size: int | None = -1, /) -> str: ...
def readable(self) -> bool: ...
def readline(self, size: int = -1, /) -> str: ...
def readlines(self, hint: int = -1, /) -> list[str]: ...
def writable(self) -> bool: ...
def write(self, s: str, /) -> int: ...
def writelines(self, lines: Iterable[str], /) -> None: ...
def popen(cmd: str, mode: str = "r", buffering: int = -1) -> _wrap_close: ...
def spawnl(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: StrOrBytesPath) -> int: ...

View file

@ -157,10 +157,10 @@ class Pickler:
def __init__(
self,
file: SupportsWrite[bytes],
protocol: int | None = ...,
protocol: int | None = None,
*,
fix_imports: bool = ...,
buffer_callback: _BufferCallback = ...,
fix_imports: bool = True,
buffer_callback: _BufferCallback = None,
) -> None: ...
def reducer_override(self, obj: Any) -> Any: ...
def dump(self, obj: Any, /) -> None: ...
@ -174,10 +174,10 @@ class Unpickler:
self,
file: _ReadableFileobj,
*,
fix_imports: bool = ...,
encoding: str = ...,
errors: str = ...,
buffers: Iterable[Any] | None = ...,
fix_imports: bool = True,
encoding: str = "ASCII",
errors: str = "strict",
buffers: Iterable[Any] | None = (),
) -> None: ...
def load(self) -> Any: ...
def find_class(self, module_name: str, global_name: str, /) -> Any: ...

View file

@ -3,17 +3,13 @@ from collections.abc import Callable
from pyexpat import errors as errors, model as model
from typing import Any, Final, final
from typing_extensions import TypeAlias
from xml.parsers.expat import ExpatError as ExpatError
EXPAT_VERSION: Final[str] # undocumented
version_info: tuple[int, int, int] # undocumented
native_encoding: str # undocumented
features: list[tuple[str, int]] # undocumented
class ExpatError(Exception):
code: int
lineno: int
offset: int
error = ExpatError
XML_PARAM_ENTITY_PARSING_NEVER: Final = 0
XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE: Final = 1

View file

@ -4,7 +4,6 @@ import sre_constants
import sys
from _typeshed import ReadableBuffer
from collections.abc import Callable, Iterator, Mapping
from sre_constants import error as error
from typing import Any, AnyStr, Generic, Literal, TypeVar, final, overload
from typing_extensions import TypeAlias
@ -54,6 +53,16 @@ if sys.version_info >= (3, 13):
_T = TypeVar("_T")
# The implementation defines this in re._constants (version_info >= 3, 11) or
# sre_constants. Typeshed has it here because its __module__ attribute is set to "re".
class error(Exception):
msg: str
pattern: str | bytes | None
pos: int | None
lineno: int
colno: int
def __init__(self, msg: str, pattern: str | bytes | None = None, pos: int | None = None) -> None: ...
@final
class Match(Generic[AnyStr]):
@property

View file

@ -27,7 +27,7 @@ def join(split_command: Iterable[str]) -> str: ...
def quote(s: str) -> str: ...
# TODO: Make generic over infile once PEP 696 is implemented.
class shlex(Iterable[str]):
class shlex:
commenters: str
wordchars: str
whitespace: str

View file

@ -109,8 +109,6 @@ from _socket import (
_RetAddress as _RetAddress,
close as close,
dup as dup,
error as error,
gaierror as gaierror,
getdefaulttimeout as getdefaulttimeout,
gethostbyaddr as gethostbyaddr,
gethostbyname as gethostbyname,
@ -121,7 +119,6 @@ from _socket import (
getservbyname as getservbyname,
getservbyport as getservbyport,
has_ipv6 as has_ipv6,
herror as herror,
htonl as htonl,
htons as htons,
if_indextoname as if_indextoname,
@ -134,7 +131,6 @@ from _socket import (
ntohl as ntohl,
ntohs as ntohs,
setdefaulttimeout as setdefaulttimeout,
timeout as timeout,
)
from _typeshed import ReadableBuffer, Unused, WriteableBuffer
from collections.abc import Iterable
@ -486,6 +482,18 @@ EBADF: int
EAGAIN: int
EWOULDBLOCK: int
# These errors are implemented in _socket at runtime
# but they consider themselves to live in socket so we'll put them here.
error = OSError
class herror(error): ...
class gaierror(error): ...
if sys.version_info >= (3, 10):
timeout = TimeoutError
else:
class timeout(error): ...
class AddressFamily(IntEnum):
AF_INET = 2
AF_INET6 = 10

View file

@ -1 +1,465 @@
from sqlite3.dbapi2 import *
import sys
from _typeshed import ReadableBuffer, StrOrBytesPath, SupportsLenAndGetItem, Unused
from collections.abc import Callable, Generator, Iterable, Iterator, Mapping, Sequence
from sqlite3.dbapi2 import (
PARSE_COLNAMES as PARSE_COLNAMES,
PARSE_DECLTYPES as PARSE_DECLTYPES,
SQLITE_ALTER_TABLE as SQLITE_ALTER_TABLE,
SQLITE_ANALYZE as SQLITE_ANALYZE,
SQLITE_ATTACH as SQLITE_ATTACH,
SQLITE_CREATE_INDEX as SQLITE_CREATE_INDEX,
SQLITE_CREATE_TABLE as SQLITE_CREATE_TABLE,
SQLITE_CREATE_TEMP_INDEX as SQLITE_CREATE_TEMP_INDEX,
SQLITE_CREATE_TEMP_TABLE as SQLITE_CREATE_TEMP_TABLE,
SQLITE_CREATE_TEMP_TRIGGER as SQLITE_CREATE_TEMP_TRIGGER,
SQLITE_CREATE_TEMP_VIEW as SQLITE_CREATE_TEMP_VIEW,
SQLITE_CREATE_TRIGGER as SQLITE_CREATE_TRIGGER,
SQLITE_CREATE_VIEW as SQLITE_CREATE_VIEW,
SQLITE_CREATE_VTABLE as SQLITE_CREATE_VTABLE,
SQLITE_DELETE as SQLITE_DELETE,
SQLITE_DENY as SQLITE_DENY,
SQLITE_DETACH as SQLITE_DETACH,
SQLITE_DONE as SQLITE_DONE,
SQLITE_DROP_INDEX as SQLITE_DROP_INDEX,
SQLITE_DROP_TABLE as SQLITE_DROP_TABLE,
SQLITE_DROP_TEMP_INDEX as SQLITE_DROP_TEMP_INDEX,
SQLITE_DROP_TEMP_TABLE as SQLITE_DROP_TEMP_TABLE,
SQLITE_DROP_TEMP_TRIGGER as SQLITE_DROP_TEMP_TRIGGER,
SQLITE_DROP_TEMP_VIEW as SQLITE_DROP_TEMP_VIEW,
SQLITE_DROP_TRIGGER as SQLITE_DROP_TRIGGER,
SQLITE_DROP_VIEW as SQLITE_DROP_VIEW,
SQLITE_DROP_VTABLE as SQLITE_DROP_VTABLE,
SQLITE_FUNCTION as SQLITE_FUNCTION,
SQLITE_IGNORE as SQLITE_IGNORE,
SQLITE_INSERT as SQLITE_INSERT,
SQLITE_OK as SQLITE_OK,
SQLITE_PRAGMA as SQLITE_PRAGMA,
SQLITE_READ as SQLITE_READ,
SQLITE_RECURSIVE as SQLITE_RECURSIVE,
SQLITE_REINDEX as SQLITE_REINDEX,
SQLITE_SAVEPOINT as SQLITE_SAVEPOINT,
SQLITE_SELECT as SQLITE_SELECT,
SQLITE_TRANSACTION as SQLITE_TRANSACTION,
SQLITE_UPDATE as SQLITE_UPDATE,
Binary as Binary,
Date as Date,
DateFromTicks as DateFromTicks,
Time as Time,
TimeFromTicks as TimeFromTicks,
TimestampFromTicks as TimestampFromTicks,
adapt as adapt,
adapters as adapters,
apilevel as apilevel,
complete_statement as complete_statement,
connect as connect,
converters as converters,
enable_callback_tracebacks as enable_callback_tracebacks,
paramstyle as paramstyle,
register_adapter as register_adapter,
register_converter as register_converter,
sqlite_version as sqlite_version,
sqlite_version_info as sqlite_version_info,
threadsafety as threadsafety,
version_info as version_info,
)
from types import TracebackType
from typing import Any, Literal, Protocol, SupportsIndex, TypeVar, final, overload
from typing_extensions import Self, TypeAlias
if sys.version_info >= (3, 12):
from sqlite3.dbapi2 import (
LEGACY_TRANSACTION_CONTROL as LEGACY_TRANSACTION_CONTROL,
SQLITE_DBCONFIG_DEFENSIVE as SQLITE_DBCONFIG_DEFENSIVE,
SQLITE_DBCONFIG_DQS_DDL as SQLITE_DBCONFIG_DQS_DDL,
SQLITE_DBCONFIG_DQS_DML as SQLITE_DBCONFIG_DQS_DML,
SQLITE_DBCONFIG_ENABLE_FKEY as SQLITE_DBCONFIG_ENABLE_FKEY,
SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER as SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER,
SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION as SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION,
SQLITE_DBCONFIG_ENABLE_QPSG as SQLITE_DBCONFIG_ENABLE_QPSG,
SQLITE_DBCONFIG_ENABLE_TRIGGER as SQLITE_DBCONFIG_ENABLE_TRIGGER,
SQLITE_DBCONFIG_ENABLE_VIEW as SQLITE_DBCONFIG_ENABLE_VIEW,
SQLITE_DBCONFIG_LEGACY_ALTER_TABLE as SQLITE_DBCONFIG_LEGACY_ALTER_TABLE,
SQLITE_DBCONFIG_LEGACY_FILE_FORMAT as SQLITE_DBCONFIG_LEGACY_FILE_FORMAT,
SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE as SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE,
SQLITE_DBCONFIG_RESET_DATABASE as SQLITE_DBCONFIG_RESET_DATABASE,
SQLITE_DBCONFIG_TRIGGER_EQP as SQLITE_DBCONFIG_TRIGGER_EQP,
SQLITE_DBCONFIG_TRUSTED_SCHEMA as SQLITE_DBCONFIG_TRUSTED_SCHEMA,
SQLITE_DBCONFIG_WRITABLE_SCHEMA as SQLITE_DBCONFIG_WRITABLE_SCHEMA,
)
if sys.version_info >= (3, 11):
from sqlite3.dbapi2 import (
SQLITE_ABORT as SQLITE_ABORT,
SQLITE_ABORT_ROLLBACK as SQLITE_ABORT_ROLLBACK,
SQLITE_AUTH as SQLITE_AUTH,
SQLITE_AUTH_USER as SQLITE_AUTH_USER,
SQLITE_BUSY as SQLITE_BUSY,
SQLITE_BUSY_RECOVERY as SQLITE_BUSY_RECOVERY,
SQLITE_BUSY_SNAPSHOT as SQLITE_BUSY_SNAPSHOT,
SQLITE_BUSY_TIMEOUT as SQLITE_BUSY_TIMEOUT,
SQLITE_CANTOPEN as SQLITE_CANTOPEN,
SQLITE_CANTOPEN_CONVPATH as SQLITE_CANTOPEN_CONVPATH,
SQLITE_CANTOPEN_DIRTYWAL as SQLITE_CANTOPEN_DIRTYWAL,
SQLITE_CANTOPEN_FULLPATH as SQLITE_CANTOPEN_FULLPATH,
SQLITE_CANTOPEN_ISDIR as SQLITE_CANTOPEN_ISDIR,
SQLITE_CANTOPEN_NOTEMPDIR as SQLITE_CANTOPEN_NOTEMPDIR,
SQLITE_CANTOPEN_SYMLINK as SQLITE_CANTOPEN_SYMLINK,
SQLITE_CONSTRAINT as SQLITE_CONSTRAINT,
SQLITE_CONSTRAINT_CHECK as SQLITE_CONSTRAINT_CHECK,
SQLITE_CONSTRAINT_COMMITHOOK as SQLITE_CONSTRAINT_COMMITHOOK,
SQLITE_CONSTRAINT_FOREIGNKEY as SQLITE_CONSTRAINT_FOREIGNKEY,
SQLITE_CONSTRAINT_FUNCTION as SQLITE_CONSTRAINT_FUNCTION,
SQLITE_CONSTRAINT_NOTNULL as SQLITE_CONSTRAINT_NOTNULL,
SQLITE_CONSTRAINT_PINNED as SQLITE_CONSTRAINT_PINNED,
SQLITE_CONSTRAINT_PRIMARYKEY as SQLITE_CONSTRAINT_PRIMARYKEY,
SQLITE_CONSTRAINT_ROWID as SQLITE_CONSTRAINT_ROWID,
SQLITE_CONSTRAINT_TRIGGER as SQLITE_CONSTRAINT_TRIGGER,
SQLITE_CONSTRAINT_UNIQUE as SQLITE_CONSTRAINT_UNIQUE,
SQLITE_CONSTRAINT_VTAB as SQLITE_CONSTRAINT_VTAB,
SQLITE_CORRUPT as SQLITE_CORRUPT,
SQLITE_CORRUPT_INDEX as SQLITE_CORRUPT_INDEX,
SQLITE_CORRUPT_SEQUENCE as SQLITE_CORRUPT_SEQUENCE,
SQLITE_CORRUPT_VTAB as SQLITE_CORRUPT_VTAB,
SQLITE_EMPTY as SQLITE_EMPTY,
SQLITE_ERROR as SQLITE_ERROR,
SQLITE_ERROR_MISSING_COLLSEQ as SQLITE_ERROR_MISSING_COLLSEQ,
SQLITE_ERROR_RETRY as SQLITE_ERROR_RETRY,
SQLITE_ERROR_SNAPSHOT as SQLITE_ERROR_SNAPSHOT,
SQLITE_FORMAT as SQLITE_FORMAT,
SQLITE_FULL as SQLITE_FULL,
SQLITE_INTERNAL as SQLITE_INTERNAL,
SQLITE_INTERRUPT as SQLITE_INTERRUPT,
SQLITE_IOERR as SQLITE_IOERR,
SQLITE_IOERR_ACCESS as SQLITE_IOERR_ACCESS,
SQLITE_IOERR_AUTH as SQLITE_IOERR_AUTH,
SQLITE_IOERR_BEGIN_ATOMIC as SQLITE_IOERR_BEGIN_ATOMIC,
SQLITE_IOERR_BLOCKED as SQLITE_IOERR_BLOCKED,
SQLITE_IOERR_CHECKRESERVEDLOCK as SQLITE_IOERR_CHECKRESERVEDLOCK,
SQLITE_IOERR_CLOSE as SQLITE_IOERR_CLOSE,
SQLITE_IOERR_COMMIT_ATOMIC as SQLITE_IOERR_COMMIT_ATOMIC,
SQLITE_IOERR_CONVPATH as SQLITE_IOERR_CONVPATH,
SQLITE_IOERR_CORRUPTFS as SQLITE_IOERR_CORRUPTFS,
SQLITE_IOERR_DATA as SQLITE_IOERR_DATA,
SQLITE_IOERR_DELETE as SQLITE_IOERR_DELETE,
SQLITE_IOERR_DELETE_NOENT as SQLITE_IOERR_DELETE_NOENT,
SQLITE_IOERR_DIR_CLOSE as SQLITE_IOERR_DIR_CLOSE,
SQLITE_IOERR_DIR_FSYNC as SQLITE_IOERR_DIR_FSYNC,
SQLITE_IOERR_FSTAT as SQLITE_IOERR_FSTAT,
SQLITE_IOERR_FSYNC as SQLITE_IOERR_FSYNC,
SQLITE_IOERR_GETTEMPPATH as SQLITE_IOERR_GETTEMPPATH,
SQLITE_IOERR_LOCK as SQLITE_IOERR_LOCK,
SQLITE_IOERR_MMAP as SQLITE_IOERR_MMAP,
SQLITE_IOERR_NOMEM as SQLITE_IOERR_NOMEM,
SQLITE_IOERR_RDLOCK as SQLITE_IOERR_RDLOCK,
SQLITE_IOERR_READ as SQLITE_IOERR_READ,
SQLITE_IOERR_ROLLBACK_ATOMIC as SQLITE_IOERR_ROLLBACK_ATOMIC,
SQLITE_IOERR_SEEK as SQLITE_IOERR_SEEK,
SQLITE_IOERR_SHMLOCK as SQLITE_IOERR_SHMLOCK,
SQLITE_IOERR_SHMMAP as SQLITE_IOERR_SHMMAP,
SQLITE_IOERR_SHMOPEN as SQLITE_IOERR_SHMOPEN,
SQLITE_IOERR_SHMSIZE as SQLITE_IOERR_SHMSIZE,
SQLITE_IOERR_SHORT_READ as SQLITE_IOERR_SHORT_READ,
SQLITE_IOERR_TRUNCATE as SQLITE_IOERR_TRUNCATE,
SQLITE_IOERR_UNLOCK as SQLITE_IOERR_UNLOCK,
SQLITE_IOERR_VNODE as SQLITE_IOERR_VNODE,
SQLITE_IOERR_WRITE as SQLITE_IOERR_WRITE,
SQLITE_LIMIT_ATTACHED as SQLITE_LIMIT_ATTACHED,
SQLITE_LIMIT_COLUMN as SQLITE_LIMIT_COLUMN,
SQLITE_LIMIT_COMPOUND_SELECT as SQLITE_LIMIT_COMPOUND_SELECT,
SQLITE_LIMIT_EXPR_DEPTH as SQLITE_LIMIT_EXPR_DEPTH,
SQLITE_LIMIT_FUNCTION_ARG as SQLITE_LIMIT_FUNCTION_ARG,
SQLITE_LIMIT_LENGTH as SQLITE_LIMIT_LENGTH,
SQLITE_LIMIT_LIKE_PATTERN_LENGTH as SQLITE_LIMIT_LIKE_PATTERN_LENGTH,
SQLITE_LIMIT_SQL_LENGTH as SQLITE_LIMIT_SQL_LENGTH,
SQLITE_LIMIT_TRIGGER_DEPTH as SQLITE_LIMIT_TRIGGER_DEPTH,
SQLITE_LIMIT_VARIABLE_NUMBER as SQLITE_LIMIT_VARIABLE_NUMBER,
SQLITE_LIMIT_VDBE_OP as SQLITE_LIMIT_VDBE_OP,
SQLITE_LIMIT_WORKER_THREADS as SQLITE_LIMIT_WORKER_THREADS,
SQLITE_LOCKED as SQLITE_LOCKED,
SQLITE_LOCKED_SHAREDCACHE as SQLITE_LOCKED_SHAREDCACHE,
SQLITE_LOCKED_VTAB as SQLITE_LOCKED_VTAB,
SQLITE_MISMATCH as SQLITE_MISMATCH,
SQLITE_MISUSE as SQLITE_MISUSE,
SQLITE_NOLFS as SQLITE_NOLFS,
SQLITE_NOMEM as SQLITE_NOMEM,
SQLITE_NOTADB as SQLITE_NOTADB,
SQLITE_NOTFOUND as SQLITE_NOTFOUND,
SQLITE_NOTICE as SQLITE_NOTICE,
SQLITE_NOTICE_RECOVER_ROLLBACK as SQLITE_NOTICE_RECOVER_ROLLBACK,
SQLITE_NOTICE_RECOVER_WAL as SQLITE_NOTICE_RECOVER_WAL,
SQLITE_OK_LOAD_PERMANENTLY as SQLITE_OK_LOAD_PERMANENTLY,
SQLITE_OK_SYMLINK as SQLITE_OK_SYMLINK,
SQLITE_PERM as SQLITE_PERM,
SQLITE_PROTOCOL as SQLITE_PROTOCOL,
SQLITE_RANGE as SQLITE_RANGE,
SQLITE_READONLY as SQLITE_READONLY,
SQLITE_READONLY_CANTINIT as SQLITE_READONLY_CANTINIT,
SQLITE_READONLY_CANTLOCK as SQLITE_READONLY_CANTLOCK,
SQLITE_READONLY_DBMOVED as SQLITE_READONLY_DBMOVED,
SQLITE_READONLY_DIRECTORY as SQLITE_READONLY_DIRECTORY,
SQLITE_READONLY_RECOVERY as SQLITE_READONLY_RECOVERY,
SQLITE_READONLY_ROLLBACK as SQLITE_READONLY_ROLLBACK,
SQLITE_ROW as SQLITE_ROW,
SQLITE_SCHEMA as SQLITE_SCHEMA,
SQLITE_TOOBIG as SQLITE_TOOBIG,
SQLITE_WARNING as SQLITE_WARNING,
SQLITE_WARNING_AUTOINDEX as SQLITE_WARNING_AUTOINDEX,
)
if sys.version_info < (3, 12):
from sqlite3.dbapi2 import enable_shared_cache as enable_shared_cache, version as version
if sys.version_info < (3, 10):
from sqlite3.dbapi2 import OptimizedUnicode as OptimizedUnicode
_CursorT = TypeVar("_CursorT", bound=Cursor)
_SqliteData: TypeAlias = str | ReadableBuffer | int | float | None
# Data that is passed through adapters can be of any type accepted by an adapter.
_AdaptedInputData: TypeAlias = _SqliteData | Any
# The Mapping must really be a dict, but making it invariant is too annoying.
_Parameters: TypeAlias = SupportsLenAndGetItem[_AdaptedInputData] | Mapping[str, _AdaptedInputData]
class _AnyParamWindowAggregateClass(Protocol):
def step(self, *args: Any) -> object: ...
def inverse(self, *args: Any) -> object: ...
def value(self) -> _SqliteData: ...
def finalize(self) -> _SqliteData: ...
class _WindowAggregateClass(Protocol):
step: Callable[..., object]
inverse: Callable[..., object]
def value(self) -> _SqliteData: ...
def finalize(self) -> _SqliteData: ...
class _AggregateProtocol(Protocol):
def step(self, value: int, /) -> object: ...
def finalize(self) -> int: ...
class _SingleParamWindowAggregateClass(Protocol):
def step(self, param: Any, /) -> object: ...
def inverse(self, param: Any, /) -> object: ...
def value(self) -> _SqliteData: ...
def finalize(self) -> _SqliteData: ...
# These classes are implemented in the C module _sqlite3. At runtime, they're imported
# from there into sqlite3.dbapi2 and from that module to here. However, they
# consider themselves to live in the sqlite3.* namespace, so we'll define them here.
class Error(Exception):
if sys.version_info >= (3, 11):
sqlite_errorcode: int
sqlite_errorname: str
class DatabaseError(Error): ...
class DataError(DatabaseError): ...
class IntegrityError(DatabaseError): ...
class InterfaceError(Error): ...
class InternalError(DatabaseError): ...
class NotSupportedError(DatabaseError): ...
class OperationalError(DatabaseError): ...
class ProgrammingError(DatabaseError): ...
class Warning(Exception): ...
class Connection:
@property
def DataError(self) -> type[DataError]: ...
@property
def DatabaseError(self) -> type[DatabaseError]: ...
@property
def Error(self) -> type[Error]: ...
@property
def IntegrityError(self) -> type[IntegrityError]: ...
@property
def InterfaceError(self) -> type[InterfaceError]: ...
@property
def InternalError(self) -> type[InternalError]: ...
@property
def NotSupportedError(self) -> type[NotSupportedError]: ...
@property
def OperationalError(self) -> type[OperationalError]: ...
@property
def ProgrammingError(self) -> type[ProgrammingError]: ...
@property
def Warning(self) -> type[Warning]: ...
@property
def in_transaction(self) -> bool: ...
isolation_level: str | None # one of '', 'DEFERRED', 'IMMEDIATE' or 'EXCLUSIVE'
@property
def total_changes(self) -> int: ...
if sys.version_info >= (3, 12):
@property
def autocommit(self) -> int: ...
@autocommit.setter
def autocommit(self, val: int) -> None: ...
row_factory: Any
text_factory: Any
if sys.version_info >= (3, 12):
def __init__(
self,
database: StrOrBytesPath,
timeout: float = ...,
detect_types: int = ...,
isolation_level: str | None = ...,
check_same_thread: bool = ...,
factory: type[Connection] | None = ...,
cached_statements: int = ...,
uri: bool = ...,
autocommit: bool = ...,
) -> None: ...
else:
def __init__(
self,
database: StrOrBytesPath,
timeout: float = ...,
detect_types: int = ...,
isolation_level: str | None = ...,
check_same_thread: bool = ...,
factory: type[Connection] | None = ...,
cached_statements: int = ...,
uri: bool = ...,
) -> None: ...
def close(self) -> None: ...
if sys.version_info >= (3, 11):
def blobopen(self, table: str, column: str, row: int, /, *, readonly: bool = False, name: str = "main") -> Blob: ...
def commit(self) -> None: ...
def create_aggregate(self, name: str, n_arg: int, aggregate_class: Callable[[], _AggregateProtocol]) -> None: ...
if sys.version_info >= (3, 11):
# num_params determines how many params will be passed to the aggregate class. We provide an overload
# for the case where num_params = 1, which is expected to be the common case.
@overload
def create_window_function(
self, name: str, num_params: Literal[1], aggregate_class: Callable[[], _SingleParamWindowAggregateClass] | None, /
) -> None: ...
# And for num_params = -1, which means the aggregate must accept any number of parameters.
@overload
def create_window_function(
self, name: str, num_params: Literal[-1], aggregate_class: Callable[[], _AnyParamWindowAggregateClass] | None, /
) -> None: ...
@overload
def create_window_function(
self, name: str, num_params: int, aggregate_class: Callable[[], _WindowAggregateClass] | None, /
) -> None: ...
def create_collation(self, name: str, callback: Callable[[str, str], int | SupportsIndex] | None, /) -> None: ...
def create_function(
self, name: str, narg: int, func: Callable[..., _SqliteData] | None, *, deterministic: bool = False
) -> None: ...
@overload
def cursor(self, factory: None = None) -> Cursor: ...
@overload
def cursor(self, factory: Callable[[Connection], _CursorT]) -> _CursorT: ...
def execute(self, sql: str, parameters: _Parameters = ..., /) -> Cursor: ...
def executemany(self, sql: str, parameters: Iterable[_Parameters], /) -> Cursor: ...
def executescript(self, sql_script: str, /) -> Cursor: ...
def interrupt(self) -> None: ...
if sys.version_info >= (3, 13):
def iterdump(self, *, filter: str | None = None) -> Generator[str, None, None]: ...
else:
def iterdump(self) -> Generator[str, None, None]: ...
def rollback(self) -> None: ...
def set_authorizer(
self, authorizer_callback: Callable[[int, str | None, str | None, str | None, str | None], int] | None
) -> None: ...
def set_progress_handler(self, progress_handler: Callable[[], int | None] | None, n: int) -> None: ...
def set_trace_callback(self, trace_callback: Callable[[str], object] | None) -> None: ...
# enable_load_extension and load_extension is not available on python distributions compiled
# without sqlite3 loadable extension support. see footnotes https://docs.python.org/3/library/sqlite3.html#f1
def enable_load_extension(self, enable: bool, /) -> None: ...
if sys.version_info >= (3, 12):
def load_extension(self, name: str, /, *, entrypoint: str | None = None) -> None: ...
else:
def load_extension(self, name: str, /) -> None: ...
def backup(
self,
target: Connection,
*,
pages: int = -1,
progress: Callable[[int, int, int], object] | None = None,
name: str = "main",
sleep: float = 0.25,
) -> None: ...
if sys.version_info >= (3, 11):
def setlimit(self, category: int, limit: int, /) -> int: ...
def getlimit(self, category: int, /) -> int: ...
def serialize(self, *, name: str = "main") -> bytes: ...
def deserialize(self, data: ReadableBuffer, /, *, name: str = "main") -> None: ...
if sys.version_info >= (3, 12):
def getconfig(self, op: int, /) -> bool: ...
def setconfig(self, op: int, enable: bool = True, /) -> bool: ...
def __call__(self, sql: str, /) -> _Statement: ...
def __enter__(self) -> Self: ...
def __exit__(
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None, /
) -> Literal[False]: ...
class Cursor(Iterator[Any]):
arraysize: int
@property
def connection(self) -> Connection: ...
# May be None, but using | Any instead to avoid slightly annoying false positives.
@property
def description(self) -> tuple[tuple[str, None, None, None, None, None, None], ...] | Any: ...
@property
def lastrowid(self) -> int | None: ...
row_factory: Callable[[Cursor, Row], object] | None
@property
def rowcount(self) -> int: ...
def __init__(self, cursor: Connection, /) -> None: ...
def close(self) -> None: ...
def execute(self, sql: str, parameters: _Parameters = (), /) -> Self: ...
def executemany(self, sql: str, seq_of_parameters: Iterable[_Parameters], /) -> Self: ...
def executescript(self, sql_script: str, /) -> Cursor: ...
def fetchall(self) -> list[Any]: ...
def fetchmany(self, size: int | None = 1) -> list[Any]: ...
# Returns either a row (as created by the row_factory) or None, but
# putting None in the return annotation causes annoying false positives.
def fetchone(self) -> Any: ...
def setinputsizes(self, sizes: Unused, /) -> None: ... # does nothing
def setoutputsize(self, size: Unused, column: Unused = None, /) -> None: ... # does nothing
def __iter__(self) -> Self: ...
def __next__(self) -> Any: ...
@final
class PrepareProtocol:
def __init__(self, *args: object, **kwargs: object) -> None: ...
class Row(Sequence[Any]):
def __init__(self, cursor: Cursor, data: tuple[Any, ...], /) -> None: ...
def keys(self) -> list[str]: ...
@overload
def __getitem__(self, key: int | str, /) -> Any: ...
@overload
def __getitem__(self, key: slice, /) -> tuple[Any, ...]: ...
def __hash__(self) -> int: ...
def __iter__(self) -> Iterator[Any]: ...
def __len__(self) -> int: ...
# These return NotImplemented for anything that is not a Row.
def __eq__(self, value: object, /) -> bool: ...
def __ge__(self, value: object, /) -> bool: ...
def __gt__(self, value: object, /) -> bool: ...
def __le__(self, value: object, /) -> bool: ...
def __lt__(self, value: object, /) -> bool: ...
def __ne__(self, value: object, /) -> bool: ...
@final
class _Statement: ...
if sys.version_info >= (3, 11):
@final
class Blob:
def close(self) -> None: ...
def read(self, length: int = -1, /) -> bytes: ...
def write(self, data: ReadableBuffer, /) -> None: ...
def tell(self) -> int: ...
# whence must be one of os.SEEK_SET, os.SEEK_CUR, os.SEEK_END
def seek(self, offset: int, origin: int = 0, /) -> None: ...
def __len__(self) -> int: ...
def __enter__(self) -> Self: ...
def __exit__(self, type: object, val: object, tb: object, /) -> Literal[False]: ...
def __getitem__(self, key: SupportsIndex | slice, /) -> int: ...
def __setitem__(self, key: SupportsIndex | slice, value: int, /) -> None: ...

View file

@ -1,22 +1,226 @@
import sqlite3
import sys
from _typeshed import ReadableBuffer, StrOrBytesPath, SupportsLenAndGetItem, Unused
from collections.abc import Callable, Generator, Iterable, Iterator, Mapping
from _sqlite3 import (
PARSE_COLNAMES as PARSE_COLNAMES,
PARSE_DECLTYPES as PARSE_DECLTYPES,
SQLITE_ALTER_TABLE as SQLITE_ALTER_TABLE,
SQLITE_ANALYZE as SQLITE_ANALYZE,
SQLITE_ATTACH as SQLITE_ATTACH,
SQLITE_CREATE_INDEX as SQLITE_CREATE_INDEX,
SQLITE_CREATE_TABLE as SQLITE_CREATE_TABLE,
SQLITE_CREATE_TEMP_INDEX as SQLITE_CREATE_TEMP_INDEX,
SQLITE_CREATE_TEMP_TABLE as SQLITE_CREATE_TEMP_TABLE,
SQLITE_CREATE_TEMP_TRIGGER as SQLITE_CREATE_TEMP_TRIGGER,
SQLITE_CREATE_TEMP_VIEW as SQLITE_CREATE_TEMP_VIEW,
SQLITE_CREATE_TRIGGER as SQLITE_CREATE_TRIGGER,
SQLITE_CREATE_VIEW as SQLITE_CREATE_VIEW,
SQLITE_CREATE_VTABLE as SQLITE_CREATE_VTABLE,
SQLITE_DELETE as SQLITE_DELETE,
SQLITE_DENY as SQLITE_DENY,
SQLITE_DETACH as SQLITE_DETACH,
SQLITE_DONE as SQLITE_DONE,
SQLITE_DROP_INDEX as SQLITE_DROP_INDEX,
SQLITE_DROP_TABLE as SQLITE_DROP_TABLE,
SQLITE_DROP_TEMP_INDEX as SQLITE_DROP_TEMP_INDEX,
SQLITE_DROP_TEMP_TABLE as SQLITE_DROP_TEMP_TABLE,
SQLITE_DROP_TEMP_TRIGGER as SQLITE_DROP_TEMP_TRIGGER,
SQLITE_DROP_TEMP_VIEW as SQLITE_DROP_TEMP_VIEW,
SQLITE_DROP_TRIGGER as SQLITE_DROP_TRIGGER,
SQLITE_DROP_VIEW as SQLITE_DROP_VIEW,
SQLITE_DROP_VTABLE as SQLITE_DROP_VTABLE,
SQLITE_FUNCTION as SQLITE_FUNCTION,
SQLITE_IGNORE as SQLITE_IGNORE,
SQLITE_INSERT as SQLITE_INSERT,
SQLITE_OK as SQLITE_OK,
SQLITE_PRAGMA as SQLITE_PRAGMA,
SQLITE_READ as SQLITE_READ,
SQLITE_RECURSIVE as SQLITE_RECURSIVE,
SQLITE_REINDEX as SQLITE_REINDEX,
SQLITE_SAVEPOINT as SQLITE_SAVEPOINT,
SQLITE_SELECT as SQLITE_SELECT,
SQLITE_TRANSACTION as SQLITE_TRANSACTION,
SQLITE_UPDATE as SQLITE_UPDATE,
adapt as adapt,
adapters as adapters,
complete_statement as complete_statement,
connect as connect,
converters as converters,
enable_callback_tracebacks as enable_callback_tracebacks,
register_adapter as register_adapter,
register_converter as register_converter,
sqlite_version as sqlite_version,
)
from datetime import date, datetime, time
from types import TracebackType
from typing import Any, Final, Literal, Protocol, SupportsIndex, TypeVar, final, overload
from typing_extensions import Self, TypeAlias
from sqlite3 import (
Connection as Connection,
Cursor as Cursor,
DatabaseError as DatabaseError,
DataError as DataError,
Error as Error,
IntegrityError as IntegrityError,
InterfaceError as InterfaceError,
InternalError as InternalError,
NotSupportedError as NotSupportedError,
OperationalError as OperationalError,
PrepareProtocol as PrepareProtocol,
ProgrammingError as ProgrammingError,
Row as Row,
Warning as Warning,
)
_T = TypeVar("_T")
_ConnectionT = TypeVar("_ConnectionT", bound=Connection)
_CursorT = TypeVar("_CursorT", bound=Cursor)
_SqliteData: TypeAlias = str | ReadableBuffer | int | float | None
# Data that is passed through adapters can be of any type accepted by an adapter.
_AdaptedInputData: TypeAlias = _SqliteData | Any
# The Mapping must really be a dict, but making it invariant is too annoying.
_Parameters: TypeAlias = SupportsLenAndGetItem[_AdaptedInputData] | Mapping[str, _AdaptedInputData]
_Adapter: TypeAlias = Callable[[_T], _SqliteData]
_Converter: TypeAlias = Callable[[bytes], Any]
if sys.version_info >= (3, 12):
from _sqlite3 import (
LEGACY_TRANSACTION_CONTROL as LEGACY_TRANSACTION_CONTROL,
SQLITE_DBCONFIG_DEFENSIVE as SQLITE_DBCONFIG_DEFENSIVE,
SQLITE_DBCONFIG_DQS_DDL as SQLITE_DBCONFIG_DQS_DDL,
SQLITE_DBCONFIG_DQS_DML as SQLITE_DBCONFIG_DQS_DML,
SQLITE_DBCONFIG_ENABLE_FKEY as SQLITE_DBCONFIG_ENABLE_FKEY,
SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER as SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER,
SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION as SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION,
SQLITE_DBCONFIG_ENABLE_QPSG as SQLITE_DBCONFIG_ENABLE_QPSG,
SQLITE_DBCONFIG_ENABLE_TRIGGER as SQLITE_DBCONFIG_ENABLE_TRIGGER,
SQLITE_DBCONFIG_ENABLE_VIEW as SQLITE_DBCONFIG_ENABLE_VIEW,
SQLITE_DBCONFIG_LEGACY_ALTER_TABLE as SQLITE_DBCONFIG_LEGACY_ALTER_TABLE,
SQLITE_DBCONFIG_LEGACY_FILE_FORMAT as SQLITE_DBCONFIG_LEGACY_FILE_FORMAT,
SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE as SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE,
SQLITE_DBCONFIG_RESET_DATABASE as SQLITE_DBCONFIG_RESET_DATABASE,
SQLITE_DBCONFIG_TRIGGER_EQP as SQLITE_DBCONFIG_TRIGGER_EQP,
SQLITE_DBCONFIG_TRUSTED_SCHEMA as SQLITE_DBCONFIG_TRUSTED_SCHEMA,
SQLITE_DBCONFIG_WRITABLE_SCHEMA as SQLITE_DBCONFIG_WRITABLE_SCHEMA,
)
if sys.version_info >= (3, 11):
from _sqlite3 import (
SQLITE_ABORT as SQLITE_ABORT,
SQLITE_ABORT_ROLLBACK as SQLITE_ABORT_ROLLBACK,
SQLITE_AUTH as SQLITE_AUTH,
SQLITE_AUTH_USER as SQLITE_AUTH_USER,
SQLITE_BUSY as SQLITE_BUSY,
SQLITE_BUSY_RECOVERY as SQLITE_BUSY_RECOVERY,
SQLITE_BUSY_SNAPSHOT as SQLITE_BUSY_SNAPSHOT,
SQLITE_BUSY_TIMEOUT as SQLITE_BUSY_TIMEOUT,
SQLITE_CANTOPEN as SQLITE_CANTOPEN,
SQLITE_CANTOPEN_CONVPATH as SQLITE_CANTOPEN_CONVPATH,
SQLITE_CANTOPEN_DIRTYWAL as SQLITE_CANTOPEN_DIRTYWAL,
SQLITE_CANTOPEN_FULLPATH as SQLITE_CANTOPEN_FULLPATH,
SQLITE_CANTOPEN_ISDIR as SQLITE_CANTOPEN_ISDIR,
SQLITE_CANTOPEN_NOTEMPDIR as SQLITE_CANTOPEN_NOTEMPDIR,
SQLITE_CANTOPEN_SYMLINK as SQLITE_CANTOPEN_SYMLINK,
SQLITE_CONSTRAINT as SQLITE_CONSTRAINT,
SQLITE_CONSTRAINT_CHECK as SQLITE_CONSTRAINT_CHECK,
SQLITE_CONSTRAINT_COMMITHOOK as SQLITE_CONSTRAINT_COMMITHOOK,
SQLITE_CONSTRAINT_FOREIGNKEY as SQLITE_CONSTRAINT_FOREIGNKEY,
SQLITE_CONSTRAINT_FUNCTION as SQLITE_CONSTRAINT_FUNCTION,
SQLITE_CONSTRAINT_NOTNULL as SQLITE_CONSTRAINT_NOTNULL,
SQLITE_CONSTRAINT_PINNED as SQLITE_CONSTRAINT_PINNED,
SQLITE_CONSTRAINT_PRIMARYKEY as SQLITE_CONSTRAINT_PRIMARYKEY,
SQLITE_CONSTRAINT_ROWID as SQLITE_CONSTRAINT_ROWID,
SQLITE_CONSTRAINT_TRIGGER as SQLITE_CONSTRAINT_TRIGGER,
SQLITE_CONSTRAINT_UNIQUE as SQLITE_CONSTRAINT_UNIQUE,
SQLITE_CONSTRAINT_VTAB as SQLITE_CONSTRAINT_VTAB,
SQLITE_CORRUPT as SQLITE_CORRUPT,
SQLITE_CORRUPT_INDEX as SQLITE_CORRUPT_INDEX,
SQLITE_CORRUPT_SEQUENCE as SQLITE_CORRUPT_SEQUENCE,
SQLITE_CORRUPT_VTAB as SQLITE_CORRUPT_VTAB,
SQLITE_EMPTY as SQLITE_EMPTY,
SQLITE_ERROR as SQLITE_ERROR,
SQLITE_ERROR_MISSING_COLLSEQ as SQLITE_ERROR_MISSING_COLLSEQ,
SQLITE_ERROR_RETRY as SQLITE_ERROR_RETRY,
SQLITE_ERROR_SNAPSHOT as SQLITE_ERROR_SNAPSHOT,
SQLITE_FORMAT as SQLITE_FORMAT,
SQLITE_FULL as SQLITE_FULL,
SQLITE_INTERNAL as SQLITE_INTERNAL,
SQLITE_INTERRUPT as SQLITE_INTERRUPT,
SQLITE_IOERR as SQLITE_IOERR,
SQLITE_IOERR_ACCESS as SQLITE_IOERR_ACCESS,
SQLITE_IOERR_AUTH as SQLITE_IOERR_AUTH,
SQLITE_IOERR_BEGIN_ATOMIC as SQLITE_IOERR_BEGIN_ATOMIC,
SQLITE_IOERR_BLOCKED as SQLITE_IOERR_BLOCKED,
SQLITE_IOERR_CHECKRESERVEDLOCK as SQLITE_IOERR_CHECKRESERVEDLOCK,
SQLITE_IOERR_CLOSE as SQLITE_IOERR_CLOSE,
SQLITE_IOERR_COMMIT_ATOMIC as SQLITE_IOERR_COMMIT_ATOMIC,
SQLITE_IOERR_CONVPATH as SQLITE_IOERR_CONVPATH,
SQLITE_IOERR_CORRUPTFS as SQLITE_IOERR_CORRUPTFS,
SQLITE_IOERR_DATA as SQLITE_IOERR_DATA,
SQLITE_IOERR_DELETE as SQLITE_IOERR_DELETE,
SQLITE_IOERR_DELETE_NOENT as SQLITE_IOERR_DELETE_NOENT,
SQLITE_IOERR_DIR_CLOSE as SQLITE_IOERR_DIR_CLOSE,
SQLITE_IOERR_DIR_FSYNC as SQLITE_IOERR_DIR_FSYNC,
SQLITE_IOERR_FSTAT as SQLITE_IOERR_FSTAT,
SQLITE_IOERR_FSYNC as SQLITE_IOERR_FSYNC,
SQLITE_IOERR_GETTEMPPATH as SQLITE_IOERR_GETTEMPPATH,
SQLITE_IOERR_LOCK as SQLITE_IOERR_LOCK,
SQLITE_IOERR_MMAP as SQLITE_IOERR_MMAP,
SQLITE_IOERR_NOMEM as SQLITE_IOERR_NOMEM,
SQLITE_IOERR_RDLOCK as SQLITE_IOERR_RDLOCK,
SQLITE_IOERR_READ as SQLITE_IOERR_READ,
SQLITE_IOERR_ROLLBACK_ATOMIC as SQLITE_IOERR_ROLLBACK_ATOMIC,
SQLITE_IOERR_SEEK as SQLITE_IOERR_SEEK,
SQLITE_IOERR_SHMLOCK as SQLITE_IOERR_SHMLOCK,
SQLITE_IOERR_SHMMAP as SQLITE_IOERR_SHMMAP,
SQLITE_IOERR_SHMOPEN as SQLITE_IOERR_SHMOPEN,
SQLITE_IOERR_SHMSIZE as SQLITE_IOERR_SHMSIZE,
SQLITE_IOERR_SHORT_READ as SQLITE_IOERR_SHORT_READ,
SQLITE_IOERR_TRUNCATE as SQLITE_IOERR_TRUNCATE,
SQLITE_IOERR_UNLOCK as SQLITE_IOERR_UNLOCK,
SQLITE_IOERR_VNODE as SQLITE_IOERR_VNODE,
SQLITE_IOERR_WRITE as SQLITE_IOERR_WRITE,
SQLITE_LIMIT_ATTACHED as SQLITE_LIMIT_ATTACHED,
SQLITE_LIMIT_COLUMN as SQLITE_LIMIT_COLUMN,
SQLITE_LIMIT_COMPOUND_SELECT as SQLITE_LIMIT_COMPOUND_SELECT,
SQLITE_LIMIT_EXPR_DEPTH as SQLITE_LIMIT_EXPR_DEPTH,
SQLITE_LIMIT_FUNCTION_ARG as SQLITE_LIMIT_FUNCTION_ARG,
SQLITE_LIMIT_LENGTH as SQLITE_LIMIT_LENGTH,
SQLITE_LIMIT_LIKE_PATTERN_LENGTH as SQLITE_LIMIT_LIKE_PATTERN_LENGTH,
SQLITE_LIMIT_SQL_LENGTH as SQLITE_LIMIT_SQL_LENGTH,
SQLITE_LIMIT_TRIGGER_DEPTH as SQLITE_LIMIT_TRIGGER_DEPTH,
SQLITE_LIMIT_VARIABLE_NUMBER as SQLITE_LIMIT_VARIABLE_NUMBER,
SQLITE_LIMIT_VDBE_OP as SQLITE_LIMIT_VDBE_OP,
SQLITE_LIMIT_WORKER_THREADS as SQLITE_LIMIT_WORKER_THREADS,
SQLITE_LOCKED as SQLITE_LOCKED,
SQLITE_LOCKED_SHAREDCACHE as SQLITE_LOCKED_SHAREDCACHE,
SQLITE_LOCKED_VTAB as SQLITE_LOCKED_VTAB,
SQLITE_MISMATCH as SQLITE_MISMATCH,
SQLITE_MISUSE as SQLITE_MISUSE,
SQLITE_NOLFS as SQLITE_NOLFS,
SQLITE_NOMEM as SQLITE_NOMEM,
SQLITE_NOTADB as SQLITE_NOTADB,
SQLITE_NOTFOUND as SQLITE_NOTFOUND,
SQLITE_NOTICE as SQLITE_NOTICE,
SQLITE_NOTICE_RECOVER_ROLLBACK as SQLITE_NOTICE_RECOVER_ROLLBACK,
SQLITE_NOTICE_RECOVER_WAL as SQLITE_NOTICE_RECOVER_WAL,
SQLITE_OK_LOAD_PERMANENTLY as SQLITE_OK_LOAD_PERMANENTLY,
SQLITE_OK_SYMLINK as SQLITE_OK_SYMLINK,
SQLITE_PERM as SQLITE_PERM,
SQLITE_PROTOCOL as SQLITE_PROTOCOL,
SQLITE_RANGE as SQLITE_RANGE,
SQLITE_READONLY as SQLITE_READONLY,
SQLITE_READONLY_CANTINIT as SQLITE_READONLY_CANTINIT,
SQLITE_READONLY_CANTLOCK as SQLITE_READONLY_CANTLOCK,
SQLITE_READONLY_DBMOVED as SQLITE_READONLY_DBMOVED,
SQLITE_READONLY_DIRECTORY as SQLITE_READONLY_DIRECTORY,
SQLITE_READONLY_RECOVERY as SQLITE_READONLY_RECOVERY,
SQLITE_READONLY_ROLLBACK as SQLITE_READONLY_ROLLBACK,
SQLITE_ROW as SQLITE_ROW,
SQLITE_SCHEMA as SQLITE_SCHEMA,
SQLITE_TOOBIG as SQLITE_TOOBIG,
SQLITE_WARNING as SQLITE_WARNING,
SQLITE_WARNING_AUTOINDEX as SQLITE_WARNING_AUTOINDEX,
)
from sqlite3 import Blob as Blob
if sys.version_info < (3, 14):
# Deprecated and removed from _sqlite3 in 3.12, but removed from here in 3.14.
version: str
if sys.version_info < (3, 12):
if sys.version_info >= (3, 10):
# deprecation wrapper that has a different name for the argument...
def enable_shared_cache(enable: int) -> None: ...
else:
from _sqlite3 import enable_shared_cache as enable_shared_cache
if sys.version_info < (3, 10):
from _sqlite3 import OptimizedUnicode as OptimizedUnicode
paramstyle: str
threadsafety: int
@ -35,527 +239,3 @@ if sys.version_info < (3, 14):
sqlite_version_info: tuple[int, int, int]
Binary = memoryview
# The remaining definitions are imported from _sqlite3.
PARSE_COLNAMES: Final[int]
PARSE_DECLTYPES: Final[int]
SQLITE_ALTER_TABLE: Final[int]
SQLITE_ANALYZE: Final[int]
SQLITE_ATTACH: Final[int]
SQLITE_CREATE_INDEX: Final[int]
SQLITE_CREATE_TABLE: Final[int]
SQLITE_CREATE_TEMP_INDEX: Final[int]
SQLITE_CREATE_TEMP_TABLE: Final[int]
SQLITE_CREATE_TEMP_TRIGGER: Final[int]
SQLITE_CREATE_TEMP_VIEW: Final[int]
SQLITE_CREATE_TRIGGER: Final[int]
SQLITE_CREATE_VIEW: Final[int]
SQLITE_CREATE_VTABLE: Final[int]
SQLITE_DELETE: Final[int]
SQLITE_DENY: Final[int]
SQLITE_DETACH: Final[int]
SQLITE_DONE: Final[int]
SQLITE_DROP_INDEX: Final[int]
SQLITE_DROP_TABLE: Final[int]
SQLITE_DROP_TEMP_INDEX: Final[int]
SQLITE_DROP_TEMP_TABLE: Final[int]
SQLITE_DROP_TEMP_TRIGGER: Final[int]
SQLITE_DROP_TEMP_VIEW: Final[int]
SQLITE_DROP_TRIGGER: Final[int]
SQLITE_DROP_VIEW: Final[int]
SQLITE_DROP_VTABLE: Final[int]
SQLITE_FUNCTION: Final[int]
SQLITE_IGNORE: Final[int]
SQLITE_INSERT: Final[int]
SQLITE_OK: Final[int]
if sys.version_info >= (3, 11):
SQLITE_LIMIT_LENGTH: Final[int]
SQLITE_LIMIT_SQL_LENGTH: Final[int]
SQLITE_LIMIT_COLUMN: Final[int]
SQLITE_LIMIT_EXPR_DEPTH: Final[int]
SQLITE_LIMIT_COMPOUND_SELECT: Final[int]
SQLITE_LIMIT_VDBE_OP: Final[int]
SQLITE_LIMIT_FUNCTION_ARG: Final[int]
SQLITE_LIMIT_ATTACHED: Final[int]
SQLITE_LIMIT_LIKE_PATTERN_LENGTH: Final[int]
SQLITE_LIMIT_VARIABLE_NUMBER: Final[int]
SQLITE_LIMIT_TRIGGER_DEPTH: Final[int]
SQLITE_LIMIT_WORKER_THREADS: Final[int]
SQLITE_PRAGMA: Final[int]
SQLITE_READ: Final[int]
SQLITE_REINDEX: Final[int]
SQLITE_RECURSIVE: Final[int]
SQLITE_SAVEPOINT: Final[int]
SQLITE_SELECT: Final[int]
SQLITE_TRANSACTION: Final[int]
SQLITE_UPDATE: Final[int]
adapters: dict[tuple[type[Any], type[Any]], _Adapter[Any]]
converters: dict[str, _Converter]
sqlite_version: str
if sys.version_info < (3, 14):
# Deprecated in 3.12, removed in 3.14.
version: str
if sys.version_info >= (3, 11):
SQLITE_ABORT: Final[int]
SQLITE_ABORT_ROLLBACK: Final[int]
SQLITE_AUTH: Final[int]
SQLITE_AUTH_USER: Final[int]
SQLITE_BUSY: Final[int]
SQLITE_BUSY_RECOVERY: Final[int]
SQLITE_BUSY_SNAPSHOT: Final[int]
SQLITE_BUSY_TIMEOUT: Final[int]
SQLITE_CANTOPEN: Final[int]
SQLITE_CANTOPEN_CONVPATH: Final[int]
SQLITE_CANTOPEN_DIRTYWAL: Final[int]
SQLITE_CANTOPEN_FULLPATH: Final[int]
SQLITE_CANTOPEN_ISDIR: Final[int]
SQLITE_CANTOPEN_NOTEMPDIR: Final[int]
SQLITE_CANTOPEN_SYMLINK: Final[int]
SQLITE_CONSTRAINT: Final[int]
SQLITE_CONSTRAINT_CHECK: Final[int]
SQLITE_CONSTRAINT_COMMITHOOK: Final[int]
SQLITE_CONSTRAINT_FOREIGNKEY: Final[int]
SQLITE_CONSTRAINT_FUNCTION: Final[int]
SQLITE_CONSTRAINT_NOTNULL: Final[int]
SQLITE_CONSTRAINT_PINNED: Final[int]
SQLITE_CONSTRAINT_PRIMARYKEY: Final[int]
SQLITE_CONSTRAINT_ROWID: Final[int]
SQLITE_CONSTRAINT_TRIGGER: Final[int]
SQLITE_CONSTRAINT_UNIQUE: Final[int]
SQLITE_CONSTRAINT_VTAB: Final[int]
SQLITE_CORRUPT: Final[int]
SQLITE_CORRUPT_INDEX: Final[int]
SQLITE_CORRUPT_SEQUENCE: Final[int]
SQLITE_CORRUPT_VTAB: Final[int]
SQLITE_EMPTY: Final[int]
SQLITE_ERROR: Final[int]
SQLITE_ERROR_MISSING_COLLSEQ: Final[int]
SQLITE_ERROR_RETRY: Final[int]
SQLITE_ERROR_SNAPSHOT: Final[int]
SQLITE_FORMAT: Final[int]
SQLITE_FULL: Final[int]
SQLITE_INTERNAL: Final[int]
SQLITE_INTERRUPT: Final[int]
SQLITE_IOERR: Final[int]
SQLITE_IOERR_ACCESS: Final[int]
SQLITE_IOERR_AUTH: Final[int]
SQLITE_IOERR_BEGIN_ATOMIC: Final[int]
SQLITE_IOERR_BLOCKED: Final[int]
SQLITE_IOERR_CHECKRESERVEDLOCK: Final[int]
SQLITE_IOERR_CLOSE: Final[int]
SQLITE_IOERR_COMMIT_ATOMIC: Final[int]
SQLITE_IOERR_CONVPATH: Final[int]
SQLITE_IOERR_CORRUPTFS: Final[int]
SQLITE_IOERR_DATA: Final[int]
SQLITE_IOERR_DELETE: Final[int]
SQLITE_IOERR_DELETE_NOENT: Final[int]
SQLITE_IOERR_DIR_CLOSE: Final[int]
SQLITE_IOERR_DIR_FSYNC: Final[int]
SQLITE_IOERR_FSTAT: Final[int]
SQLITE_IOERR_FSYNC: Final[int]
SQLITE_IOERR_GETTEMPPATH: Final[int]
SQLITE_IOERR_LOCK: Final[int]
SQLITE_IOERR_MMAP: Final[int]
SQLITE_IOERR_NOMEM: Final[int]
SQLITE_IOERR_RDLOCK: Final[int]
SQLITE_IOERR_READ: Final[int]
SQLITE_IOERR_ROLLBACK_ATOMIC: Final[int]
SQLITE_IOERR_SEEK: Final[int]
SQLITE_IOERR_SHMLOCK: Final[int]
SQLITE_IOERR_SHMMAP: Final[int]
SQLITE_IOERR_SHMOPEN: Final[int]
SQLITE_IOERR_SHMSIZE: Final[int]
SQLITE_IOERR_SHORT_READ: Final[int]
SQLITE_IOERR_TRUNCATE: Final[int]
SQLITE_IOERR_UNLOCK: Final[int]
SQLITE_IOERR_VNODE: Final[int]
SQLITE_IOERR_WRITE: Final[int]
SQLITE_LOCKED: Final[int]
SQLITE_LOCKED_SHAREDCACHE: Final[int]
SQLITE_LOCKED_VTAB: Final[int]
SQLITE_MISMATCH: Final[int]
SQLITE_MISUSE: Final[int]
SQLITE_NOLFS: Final[int]
SQLITE_NOMEM: Final[int]
SQLITE_NOTADB: Final[int]
SQLITE_NOTFOUND: Final[int]
SQLITE_NOTICE: Final[int]
SQLITE_NOTICE_RECOVER_ROLLBACK: Final[int]
SQLITE_NOTICE_RECOVER_WAL: Final[int]
SQLITE_OK_LOAD_PERMANENTLY: Final[int]
SQLITE_OK_SYMLINK: Final[int]
SQLITE_PERM: Final[int]
SQLITE_PROTOCOL: Final[int]
SQLITE_RANGE: Final[int]
SQLITE_READONLY: Final[int]
SQLITE_READONLY_CANTINIT: Final[int]
SQLITE_READONLY_CANTLOCK: Final[int]
SQLITE_READONLY_DBMOVED: Final[int]
SQLITE_READONLY_DIRECTORY: Final[int]
SQLITE_READONLY_RECOVERY: Final[int]
SQLITE_READONLY_ROLLBACK: Final[int]
SQLITE_ROW: Final[int]
SQLITE_SCHEMA: Final[int]
SQLITE_TOOBIG: Final[int]
SQLITE_WARNING: Final[int]
SQLITE_WARNING_AUTOINDEX: Final[int]
if sys.version_info >= (3, 12):
LEGACY_TRANSACTION_CONTROL: Final[int]
SQLITE_DBCONFIG_DEFENSIVE: Final[int]
SQLITE_DBCONFIG_DQS_DDL: Final[int]
SQLITE_DBCONFIG_DQS_DML: Final[int]
SQLITE_DBCONFIG_ENABLE_FKEY: Final[int]
SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER: Final[int]
SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION: Final[int]
SQLITE_DBCONFIG_ENABLE_QPSG: Final[int]
SQLITE_DBCONFIG_ENABLE_TRIGGER: Final[int]
SQLITE_DBCONFIG_ENABLE_VIEW: Final[int]
SQLITE_DBCONFIG_LEGACY_ALTER_TABLE: Final[int]
SQLITE_DBCONFIG_LEGACY_FILE_FORMAT: Final[int]
SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE: Final[int]
SQLITE_DBCONFIG_RESET_DATABASE: Final[int]
SQLITE_DBCONFIG_TRIGGER_EQP: Final[int]
SQLITE_DBCONFIG_TRUSTED_SCHEMA: Final[int]
SQLITE_DBCONFIG_WRITABLE_SCHEMA: Final[int]
# Can take or return anything depending on what's in the registry.
@overload
def adapt(obj: Any, proto: Any, /) -> Any: ...
@overload
def adapt(obj: Any, proto: Any, alt: _T, /) -> Any | _T: ...
def complete_statement(statement: str) -> bool: ...
if sys.version_info >= (3, 12):
@overload
def connect(
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None = "DEFERRED",
check_same_thread: bool = True,
cached_statements: int = 128,
uri: bool = False,
*,
autocommit: bool = ...,
) -> Connection: ...
@overload
def connect(
database: StrOrBytesPath,
timeout: float,
detect_types: int,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None,
check_same_thread: bool,
factory: type[_ConnectionT],
cached_statements: int = 128,
uri: bool = False,
*,
autocommit: bool = ...,
) -> _ConnectionT: ...
@overload
def connect(
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None = "DEFERRED",
check_same_thread: bool = True,
*,
factory: type[_ConnectionT],
cached_statements: int = 128,
uri: bool = False,
autocommit: bool = ...,
) -> _ConnectionT: ...
else:
@overload
def connect(
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None = "DEFERRED",
check_same_thread: bool = True,
cached_statements: int = 128,
uri: bool = False,
) -> Connection: ...
@overload
def connect(
database: StrOrBytesPath,
timeout: float,
detect_types: int,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None,
check_same_thread: bool,
factory: type[_ConnectionT],
cached_statements: int = 128,
uri: bool = False,
) -> _ConnectionT: ...
@overload
def connect(
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None = "DEFERRED",
check_same_thread: bool = True,
*,
factory: type[_ConnectionT],
cached_statements: int = 128,
uri: bool = False,
) -> _ConnectionT: ...
def enable_callback_tracebacks(enable: bool, /) -> None: ...
if sys.version_info < (3, 12):
# takes a pos-or-keyword argument because there is a C wrapper
def enable_shared_cache(enable: int) -> None: ...
if sys.version_info >= (3, 10):
def register_adapter(type: type[_T], adapter: _Adapter[_T], /) -> None: ...
def register_converter(typename: str, converter: _Converter, /) -> None: ...
else:
def register_adapter(type: type[_T], caster: _Adapter[_T], /) -> None: ...
def register_converter(name: str, converter: _Converter, /) -> None: ...
class _AggregateProtocol(Protocol):
def step(self, value: int, /) -> object: ...
def finalize(self) -> int: ...
class _SingleParamWindowAggregateClass(Protocol):
def step(self, param: Any, /) -> object: ...
def inverse(self, param: Any, /) -> object: ...
def value(self) -> _SqliteData: ...
def finalize(self) -> _SqliteData: ...
class _AnyParamWindowAggregateClass(Protocol):
def step(self, *args: Any) -> object: ...
def inverse(self, *args: Any) -> object: ...
def value(self) -> _SqliteData: ...
def finalize(self) -> _SqliteData: ...
class _WindowAggregateClass(Protocol):
step: Callable[..., object]
inverse: Callable[..., object]
def value(self) -> _SqliteData: ...
def finalize(self) -> _SqliteData: ...
class Connection:
@property
def DataError(self) -> type[sqlite3.DataError]: ...
@property
def DatabaseError(self) -> type[sqlite3.DatabaseError]: ...
@property
def Error(self) -> type[sqlite3.Error]: ...
@property
def IntegrityError(self) -> type[sqlite3.IntegrityError]: ...
@property
def InterfaceError(self) -> type[sqlite3.InterfaceError]: ...
@property
def InternalError(self) -> type[sqlite3.InternalError]: ...
@property
def NotSupportedError(self) -> type[sqlite3.NotSupportedError]: ...
@property
def OperationalError(self) -> type[sqlite3.OperationalError]: ...
@property
def ProgrammingError(self) -> type[sqlite3.ProgrammingError]: ...
@property
def Warning(self) -> type[sqlite3.Warning]: ...
@property
def in_transaction(self) -> bool: ...
isolation_level: str | None # one of '', 'DEFERRED', 'IMMEDIATE' or 'EXCLUSIVE'
@property
def total_changes(self) -> int: ...
if sys.version_info >= (3, 12):
@property
def autocommit(self) -> int: ...
@autocommit.setter
def autocommit(self, val: int) -> None: ...
row_factory: Any
text_factory: Any
if sys.version_info >= (3, 12):
def __init__(
self,
database: StrOrBytesPath,
timeout: float = ...,
detect_types: int = ...,
isolation_level: str | None = ...,
check_same_thread: bool = ...,
factory: type[Connection] | None = ...,
cached_statements: int = ...,
uri: bool = ...,
autocommit: bool = ...,
) -> None: ...
else:
def __init__(
self,
database: StrOrBytesPath,
timeout: float = ...,
detect_types: int = ...,
isolation_level: str | None = ...,
check_same_thread: bool = ...,
factory: type[Connection] | None = ...,
cached_statements: int = ...,
uri: bool = ...,
) -> None: ...
def close(self) -> None: ...
if sys.version_info >= (3, 11):
def blobopen(self, table: str, column: str, row: int, /, *, readonly: bool = False, name: str = "main") -> Blob: ...
def commit(self) -> None: ...
def create_aggregate(self, name: str, n_arg: int, aggregate_class: Callable[[], _AggregateProtocol]) -> None: ...
if sys.version_info >= (3, 11):
# num_params determines how many params will be passed to the aggregate class. We provide an overload
# for the case where num_params = 1, which is expected to be the common case.
@overload
def create_window_function(
self, name: str, num_params: Literal[1], aggregate_class: Callable[[], _SingleParamWindowAggregateClass] | None, /
) -> None: ...
# And for num_params = -1, which means the aggregate must accept any number of parameters.
@overload
def create_window_function(
self, name: str, num_params: Literal[-1], aggregate_class: Callable[[], _AnyParamWindowAggregateClass] | None, /
) -> None: ...
@overload
def create_window_function(
self, name: str, num_params: int, aggregate_class: Callable[[], _WindowAggregateClass] | None, /
) -> None: ...
def create_collation(self, name: str, callback: Callable[[str, str], int | SupportsIndex] | None, /) -> None: ...
def create_function(
self, name: str, narg: int, func: Callable[..., _SqliteData] | None, *, deterministic: bool = False
) -> None: ...
@overload
def cursor(self, factory: None = None) -> Cursor: ...
@overload
def cursor(self, factory: Callable[[Connection], _CursorT]) -> _CursorT: ...
def execute(self, sql: str, parameters: _Parameters = ..., /) -> Cursor: ...
def executemany(self, sql: str, parameters: Iterable[_Parameters], /) -> Cursor: ...
def executescript(self, sql_script: str, /) -> Cursor: ...
def interrupt(self) -> None: ...
if sys.version_info >= (3, 13):
def iterdump(self, *, filter: str | None = None) -> Generator[str, None, None]: ...
else:
def iterdump(self) -> Generator[str, None, None]: ...
def rollback(self) -> None: ...
def set_authorizer(
self, authorizer_callback: Callable[[int, str | None, str | None, str | None, str | None], int] | None
) -> None: ...
def set_progress_handler(self, progress_handler: Callable[[], int | None] | None, n: int) -> None: ...
def set_trace_callback(self, trace_callback: Callable[[str], object] | None) -> None: ...
# enable_load_extension and load_extension is not available on python distributions compiled
# without sqlite3 loadable extension support. see footnotes https://docs.python.org/3/library/sqlite3.html#f1
def enable_load_extension(self, enable: bool, /) -> None: ...
def load_extension(self, name: str, /) -> None: ...
def backup(
self,
target: Connection,
*,
pages: int = -1,
progress: Callable[[int, int, int], object] | None = None,
name: str = "main",
sleep: float = 0.25,
) -> None: ...
if sys.version_info >= (3, 11):
def setlimit(self, category: int, limit: int, /) -> int: ...
def getlimit(self, category: int, /) -> int: ...
def serialize(self, *, name: str = "main") -> bytes: ...
def deserialize(self, data: ReadableBuffer, /, *, name: str = "main") -> None: ...
if sys.version_info >= (3, 12):
def getconfig(self, op: int, /) -> bool: ...
def setconfig(self, op: int, enable: bool = True, /) -> bool: ...
def __call__(self, sql: str, /) -> _Statement: ...
def __enter__(self) -> Self: ...
def __exit__(
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None, /
) -> Literal[False]: ...
class Cursor(Iterator[Any]):
arraysize: int
@property
def connection(self) -> Connection: ...
# May be None, but using | Any instead to avoid slightly annoying false positives.
@property
def description(self) -> tuple[tuple[str, None, None, None, None, None, None], ...] | Any: ...
@property
def lastrowid(self) -> int | None: ...
row_factory: Callable[[Cursor, Row], object] | None
@property
def rowcount(self) -> int: ...
def __init__(self, cursor: Connection, /) -> None: ...
def close(self) -> None: ...
def execute(self, sql: str, parameters: _Parameters = (), /) -> Self: ...
def executemany(self, sql: str, seq_of_parameters: Iterable[_Parameters], /) -> Self: ...
def executescript(self, sql_script: str, /) -> Cursor: ...
def fetchall(self) -> list[Any]: ...
def fetchmany(self, size: int | None = 1) -> list[Any]: ...
# Returns either a row (as created by the row_factory) or None, but
# putting None in the return annotation causes annoying false positives.
def fetchone(self) -> Any: ...
def setinputsizes(self, sizes: Unused, /) -> None: ... # does nothing
def setoutputsize(self, size: Unused, column: Unused = None, /) -> None: ... # does nothing
def __iter__(self) -> Self: ...
def __next__(self) -> Any: ...
class Error(Exception):
if sys.version_info >= (3, 11):
sqlite_errorcode: int
sqlite_errorname: str
class DatabaseError(Error): ...
class DataError(DatabaseError): ...
class IntegrityError(DatabaseError): ...
class InterfaceError(Error): ...
class InternalError(DatabaseError): ...
class NotSupportedError(DatabaseError): ...
class OperationalError(DatabaseError): ...
if sys.version_info < (3, 10):
OptimizedUnicode = str
@final
class PrepareProtocol:
def __init__(self, *args: object, **kwargs: object) -> None: ...
class ProgrammingError(DatabaseError): ...
class Row:
def __init__(self, cursor: Cursor, data: tuple[Any, ...], /) -> None: ...
def keys(self) -> list[str]: ...
@overload
def __getitem__(self, key: int | str, /) -> Any: ...
@overload
def __getitem__(self, key: slice, /) -> tuple[Any, ...]: ...
def __hash__(self) -> int: ...
def __iter__(self) -> Iterator[Any]: ...
def __len__(self) -> int: ...
# These return NotImplemented for anything that is not a Row.
def __eq__(self, value: object, /) -> bool: ...
def __ge__(self, value: object, /) -> bool: ...
def __gt__(self, value: object, /) -> bool: ...
def __le__(self, value: object, /) -> bool: ...
def __lt__(self, value: object, /) -> bool: ...
def __ne__(self, value: object, /) -> bool: ...
@final
class _Statement: ...
class Warning(Exception): ...
if sys.version_info >= (3, 11):
@final
class Blob:
def close(self) -> None: ...
def read(self, length: int = -1, /) -> bytes: ...
def write(self, data: ReadableBuffer, /) -> None: ...
def tell(self) -> int: ...
# whence must be one of os.SEEK_SET, os.SEEK_CUR, os.SEEK_END
def seek(self, offset: int, origin: int = 0, /) -> None: ...
def __len__(self) -> int: ...
def __enter__(self) -> Self: ...
def __exit__(self, type: object, val: object, tb: object, /) -> Literal[False]: ...
def __getitem__(self, key: SupportsIndex | slice, /) -> int: ...
def __setitem__(self, key: SupportsIndex | slice, value: int, /) -> None: ...

View file

@ -1,4 +1,5 @@
import sys
from re import error as error
from typing import Any
from typing_extensions import Self
@ -6,14 +7,6 @@ MAXGROUPS: int
MAGIC: int
class error(Exception):
msg: str
pattern: str | bytes | None
pos: int | None
lineno: int
colno: int
def __init__(self, msg: str, pattern: str | bytes | None = None, pos: int | None = None) -> None: ...
class _NamedIntConstant(int):
name: Any
def __new__(cls, value: int, name: str) -> Self: ...

View file

@ -1,18 +1,51 @@
import enum
import socket
import sys
from _ssl import (
_DEFAULT_CIPHERS as _DEFAULT_CIPHERS,
_OPENSSL_API_VERSION as _OPENSSL_API_VERSION,
HAS_ALPN as HAS_ALPN,
HAS_ECDH as HAS_ECDH,
HAS_NPN as HAS_NPN,
HAS_SNI as HAS_SNI,
OPENSSL_VERSION as OPENSSL_VERSION,
OPENSSL_VERSION_INFO as OPENSSL_VERSION_INFO,
OPENSSL_VERSION_NUMBER as OPENSSL_VERSION_NUMBER,
HAS_SSLv2 as HAS_SSLv2,
HAS_SSLv3 as HAS_SSLv3,
HAS_TLSv1 as HAS_TLSv1,
HAS_TLSv1_1 as HAS_TLSv1_1,
HAS_TLSv1_2 as HAS_TLSv1_2,
HAS_TLSv1_3 as HAS_TLSv1_3,
MemoryBIO as MemoryBIO,
RAND_add as RAND_add,
RAND_bytes as RAND_bytes,
RAND_status as RAND_status,
SSLSession as SSLSession,
_PasswordType as _PasswordType, # typeshed only, but re-export for other type stubs to use
_SSLContext,
)
from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer
from collections.abc import Callable, Iterable
from typing import Any, Literal, NamedTuple, TypedDict, final, overload
from typing import Any, Literal, NamedTuple, TypedDict, overload
from typing_extensions import Never, Self, TypeAlias
if sys.version_info >= (3, 13):
from _ssl import HAS_PSK as HAS_PSK
if sys.version_info < (3, 12):
from _ssl import RAND_pseudo_bytes as RAND_pseudo_bytes
if sys.version_info < (3, 10):
from _ssl import RAND_egd as RAND_egd
if sys.platform == "win32":
from _ssl import enum_certificates as enum_certificates, enum_crls as enum_crls
_PCTRTT: TypeAlias = tuple[tuple[str, str], ...]
_PCTRTTT: TypeAlias = tuple[_PCTRTT, ...]
_PeerCertRetDictType: TypeAlias = dict[str, str | _PCTRTTT | _PCTRTT]
_PeerCertRetType: TypeAlias = _PeerCertRetDictType | bytes | None
_EnumRetType: TypeAlias = list[tuple[bytes, str, set[str] | bool]]
_PasswordType: TypeAlias = Callable[[], str | bytes | bytearray] | str | bytes | bytearray
_SrvnmeCbType: TypeAlias = Callable[[SSLSocket | SSLObject, str | None, SSLSocket], int | None]
socket_error = OSError
@ -98,15 +131,6 @@ else:
_create_default_https_context: Callable[..., SSLContext]
def RAND_bytes(n: int, /) -> bytes: ...
if sys.version_info < (3, 12):
def RAND_pseudo_bytes(n: int, /) -> tuple[bytes, bool]: ...
def RAND_status() -> bool: ...
def RAND_egd(path: str) -> None: ...
def RAND_add(string: str | ReadableBuffer, entropy: float, /) -> None: ...
if sys.version_info < (3, 12):
def match_hostname(cert: _PeerCertRetDictType, hostname: str) -> None: ...
@ -133,10 +157,6 @@ class DefaultVerifyPaths(NamedTuple):
def get_default_verify_paths() -> DefaultVerifyPaths: ...
if sys.platform == "win32":
def enum_certificates(store_name: str) -> _EnumRetType: ...
def enum_crls(store_name: str) -> _EnumRetType: ...
class VerifyMode(enum.IntEnum):
CERT_NONE = 0
CERT_OPTIONAL = 1
@ -229,21 +249,8 @@ if sys.version_info >= (3, 11) or sys.platform == "linux":
OP_IGNORE_UNEXPECTED_EOF: Options
HAS_NEVER_CHECK_COMMON_NAME: bool
HAS_SSLv2: bool
HAS_SSLv3: bool
HAS_TLSv1: bool
HAS_TLSv1_1: bool
HAS_TLSv1_2: bool
HAS_TLSv1_3: bool
HAS_ALPN: bool
HAS_ECDH: bool
HAS_SNI: bool
HAS_NPN: bool
CHANNEL_BINDING_TYPES: list[str]
OPENSSL_VERSION: str
OPENSSL_VERSION_INFO: tuple[int, int, int, int, int]
OPENSSL_VERSION_NUMBER: int
CHANNEL_BINDING_TYPES: list[str]
class AlertDescription(enum.IntEnum):
ALERT_DESCRIPTION_ACCESS_DENIED = 49
@ -379,17 +386,15 @@ class TLSVersion(enum.IntEnum):
TLSv1_2 = 771
TLSv1_3 = 772
class SSLContext:
check_hostname: bool
class SSLContext(_SSLContext):
options: Options
verify_flags: VerifyFlags
verify_mode: VerifyMode
@property
def protocol(self) -> _SSLMethod: ...
def protocol(self) -> _SSLMethod: ... # type: ignore[override]
hostname_checks_common_name: bool
maximum_version: TLSVersion
minimum_version: TLSVersion
sni_callback: Callable[[SSLObject, str, SSLContext], None | int] | None
# The following two attributes have class-level defaults.
# However, the docs explicitly state that it's OK to override these attributes on instances,
# so making these ClassVars wouldn't be appropriate
@ -406,10 +411,6 @@ class SSLContext:
else:
def __new__(cls, protocol: int = ..., *args: Any, **kwargs: Any) -> Self: ...
def cert_store_stats(self) -> dict[str, int]: ...
def load_cert_chain(
self, certfile: StrOrBytesPath, keyfile: StrOrBytesPath | None = None, password: _PasswordType | None = None
) -> None: ...
def load_default_certs(self, purpose: Purpose = ...) -> None: ...
def load_verify_locations(
self,
@ -448,7 +449,6 @@ class SSLContext:
server_hostname: str | bytes | None = None,
session: SSLSession | None = None,
) -> SSLObject: ...
def session_stats(self) -> dict[str, int]: ...
class SSLObject:
context: SSLContext
@ -483,28 +483,6 @@ class SSLObject:
def get_verified_chain(self) -> list[bytes]: ...
def get_unverified_chain(self) -> list[bytes]: ...
@final
class MemoryBIO:
pending: int
eof: bool
def read(self, size: int = -1, /) -> bytes: ...
def write(self, b: ReadableBuffer, /) -> int: ...
def write_eof(self) -> None: ...
@final
class SSLSession:
@property
def has_ticket(self) -> bool: ...
@property
def id(self) -> bytes: ...
@property
def ticket_lifetime_hint(self) -> int: ...
@property
def time(self) -> int: ...
@property
def timeout(self) -> int: ...
def __eq__(self, value: object, /) -> bool: ...
class SSLErrorNumber(enum.IntEnum):
SSL_ERROR_EOF = 8
SSL_ERROR_INVALID_ERROR_CODE = 10

View file

@ -103,12 +103,10 @@ PAX_NAME_FIELDS: set[str]
ENCODING: str
_FileCreationModes: TypeAlias = Literal["a", "w", "x"]
@overload
def open(
name: StrOrBytesPath | None = None,
mode: str = "r",
mode: Literal["r", "r:*", "r:", "r:gz", "r:bz2", "r:xz"] = "r",
fileobj: IO[bytes] | None = None,
bufsize: int = 10240,
*,
@ -121,13 +119,11 @@ def open(
pax_headers: Mapping[str, str] | None = ...,
debug: int | None = ...,
errorlevel: int | None = ...,
compresslevel: int | None = ...,
preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ...,
) -> TarFile: ...
@overload
def open(
name: StrOrBytesPath | None = None,
mode: _FileCreationModes = ...,
name: StrOrBytesPath | None,
mode: Literal["x", "x:", "a", "a:", "w", "w:"],
fileobj: _Fileobj | None = None,
bufsize: int = 10240,
*,
@ -140,7 +136,116 @@ def open(
pax_headers: Mapping[str, str] | None = ...,
debug: int | None = ...,
errorlevel: int | None = ...,
compresslevel: int | None = ...,
) -> TarFile: ...
@overload
def open(
name: StrOrBytesPath | None = None,
*,
mode: Literal["x", "x:", "a", "a:", "w", "w:"],
fileobj: _Fileobj | None = None,
bufsize: int = 10240,
format: int | None = ...,
tarinfo: type[TarInfo] | None = ...,
dereference: bool | None = ...,
ignore_zeros: bool | None = ...,
encoding: str | None = ...,
errors: str = ...,
pax_headers: Mapping[str, str] | None = ...,
debug: int | None = ...,
errorlevel: int | None = ...,
) -> TarFile: ...
@overload
def open(
name: StrOrBytesPath | None,
mode: Literal["x:gz", "x:bz2", "w:gz", "w:bz2"],
fileobj: _Fileobj | None = None,
bufsize: int = 10240,
*,
format: int | None = ...,
tarinfo: type[TarInfo] | None = ...,
dereference: bool | None = ...,
ignore_zeros: bool | None = ...,
encoding: str | None = ...,
errors: str = ...,
pax_headers: Mapping[str, str] | None = ...,
debug: int | None = ...,
errorlevel: int | None = ...,
compresslevel: int = 9,
) -> TarFile: ...
@overload
def open(
name: StrOrBytesPath | None = None,
*,
mode: Literal["x:gz", "x:bz2", "w:gz", "w:bz2"],
fileobj: _Fileobj | None = None,
bufsize: int = 10240,
format: int | None = ...,
tarinfo: type[TarInfo] | None = ...,
dereference: bool | None = ...,
ignore_zeros: bool | None = ...,
encoding: str | None = ...,
errors: str = ...,
pax_headers: Mapping[str, str] | None = ...,
debug: int | None = ...,
errorlevel: int | None = ...,
compresslevel: int = 9,
) -> TarFile: ...
@overload
def open(
name: StrOrBytesPath | None,
mode: Literal["x:xz", "w:xz"],
fileobj: _Fileobj | None = None,
bufsize: int = 10240,
*,
format: int | None = ...,
tarinfo: type[TarInfo] | None = ...,
dereference: bool | None = ...,
ignore_zeros: bool | None = ...,
encoding: str | None = ...,
errors: str = ...,
pax_headers: Mapping[str, str] | None = ...,
debug: int | None = ...,
errorlevel: int | None = ...,
preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ...,
) -> TarFile: ...
@overload
def open(
name: StrOrBytesPath | None = None,
*,
mode: Literal["x:xz", "w:xz"],
fileobj: _Fileobj | None = None,
bufsize: int = 10240,
format: int | None = ...,
tarinfo: type[TarInfo] | None = ...,
dereference: bool | None = ...,
ignore_zeros: bool | None = ...,
encoding: str | None = ...,
errors: str = ...,
pax_headers: Mapping[str, str] | None = ...,
debug: int | None = ...,
errorlevel: int | None = ...,
preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ...,
) -> TarFile: ...
# TODO: Temporary fallback for modes containing pipe characters. These don't
# work with mypy 1.10, but this should be fixed with mypy 1.11.
# https://github.com/python/typeshed/issues/12182
@overload
def open(
name: StrOrBytesPath | None = None,
*,
mode: str,
fileobj: IO[bytes] | None = None,
bufsize: int = 10240,
format: int | None = ...,
tarinfo: type[TarInfo] | None = ...,
dereference: bool | None = ...,
ignore_zeros: bool | None = ...,
encoding: str | None = ...,
errors: str = ...,
pax_headers: Mapping[str, str] | None = ...,
debug: int | None = ...,
errorlevel: int | None = ...,
preset: int | None = ...,
) -> TarFile: ...

View file

@ -133,7 +133,7 @@ class Untokenizer:
def untokenize(iterable: Iterable[_Token]) -> 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]: ... # undocumented
def generate_tokens(readline: Callable[[], str]) -> Generator[TokenInfo, None, None]: ...
def open(filename: FileDescriptorOrPath) -> TextIO: ...
def group(*choices: str) -> str: ... # undocumented
def any(*choices: str) -> str: ... # undocumented

View file

@ -231,7 +231,7 @@ class TracebackException:
if sys.version_info >= (3, 11):
def print(self, *, file: SupportsWrite[str] | None = None, chain: bool = True) -> None: ...
class FrameSummary(Iterable[Any]):
class FrameSummary:
if sys.version_info >= (3, 11):
def __init__(
self,
@ -276,6 +276,8 @@ class FrameSummary(Iterable[Any]):
def __getitem__(self, pos: Literal[3]) -> str | None: ...
@overload
def __getitem__(self, pos: int) -> Any: ...
@overload
def __getitem__(self, pos: slice) -> tuple[Any, ...]: ...
def __iter__(self) -> Iterator[Any]: ...
def __eq__(self, other: object) -> bool: ...
def __len__(self) -> Literal[4]: ...

View file

@ -424,6 +424,8 @@ class MethodType:
@property
def __closure__(self) -> tuple[CellType, ...] | None: ... # inherited from the added function
@property
def __code__(self) -> CodeType: ... # inherited from the added function
@property
def __defaults__(self) -> tuple[Any, ...] | None: ... # inherited from the added function
@property
def __func__(self) -> Callable[..., Any]: ...

View file

@ -363,7 +363,7 @@ class _patcher:
patch: _patcher
class MagicMixin:
class MagicMixin(Base):
def __init__(self, *args: Any, **kw: Any) -> None: ...
class NonCallableMagicMock(MagicMixin, NonCallableMock): ...
@ -393,7 +393,7 @@ class AsyncMock(AsyncMockMixin, AsyncMagicMixin, Mock):
# But, `NonCallableMock` super-class has the better version.
def reset_mock(self, visited: Any = None, *, return_value: bool = False, side_effect: bool = False) -> None: ...
class MagicProxy:
class MagicProxy(Base):
name: str
parent: Any
def __init__(self, name: str, parent: Any) -> None: ...

View file

@ -5,7 +5,7 @@ from typing_extensions import TypeAlias
_TestType: TypeAlias = unittest.case.TestCase | TestSuite
class BaseTestSuite(Iterable[_TestType]):
class BaseTestSuite:
_tests: list[unittest.case.TestCase]
_removed_tests: int
def __init__(self, tests: Iterable[_TestType] = ()) -> None: ...

View file

@ -1,19 +1,14 @@
import sys
from _typeshed import SupportsKeysAndGetItem
from _weakref import (
CallableProxyType as CallableProxyType,
ProxyType as ProxyType,
ReferenceType as ReferenceType,
getweakrefcount as getweakrefcount,
getweakrefs as getweakrefs,
proxy as proxy,
ref as ref,
)
from _weakref import getweakrefcount as getweakrefcount, getweakrefs as getweakrefs, proxy as proxy
from _weakrefset import WeakSet as WeakSet
from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping
from typing import Any, Generic, TypeVar, overload
from typing import Any, Generic, TypeVar, final, overload
from typing_extensions import ParamSpec, Self
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = [
"ref",
"proxy",
@ -40,11 +35,39 @@ _P = ParamSpec("_P")
ProxyTypes: tuple[type[Any], ...]
# These classes are implemented in C and imported from _weakref at runtime. However,
# they consider themselves to live in the weakref module for sys.version_info >= (3, 11),
# so defining their stubs here means we match their __module__ value.
# Prior to 3.11 they did not declare a module for themselves and ended up looking like they
# came from the builtin module at runtime, which was just wrong, and we won't attempt to
# duplicate that.
@final
class CallableProxyType(Generic[_CallableT]): # "weakcallableproxy"
def __eq__(self, value: object, /) -> bool: ...
def __getattr__(self, attr: str) -> Any: ...
__call__: _CallableT
@final
class ProxyType(Generic[_T]): # "weakproxy"
def __eq__(self, value: object, /) -> bool: ...
def __getattr__(self, attr: str) -> Any: ...
class ReferenceType(Generic[_T]): # "weakref"
__callback__: Callable[[Self], Any]
def __new__(cls, o: _T, callback: Callable[[Self], Any] | None = ..., /) -> Self: ...
def __call__(self) -> _T | None: ...
def __eq__(self, value: object, /) -> bool: ...
def __hash__(self) -> int: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
ref = ReferenceType
# everything below here is implemented in weakref.py
class WeakMethod(ref[_CallableT]):
# `ref` is implemented in `C` so positional-only arguments are enforced, but not in `WeakMethod`.
def __new__( # pyright: ignore[reportInconsistentConstructor]
cls, meth: _CallableT, callback: Callable[[Self], Any] | None = None
) -> Self: ...
def __new__(cls, meth: _CallableT, callback: Callable[[Self], Any] | None = None) -> Self: ...
def __call__(self) -> _CallableT | None: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
@ -103,8 +126,8 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]):
class KeyedRef(ref[_T], Generic[_KT, _T]):
key: _KT
def __new__(type, ob: _T, callback: Callable[[_T], Any], key: _KT) -> Self: ...
def __init__(self, ob: _T, callback: Callable[[_T], Any], key: _KT) -> None: ...
def __new__(type, ob: _T, callback: Callable[[Self], Any], key: _KT) -> Self: ...
def __init__(self, ob: _T, callback: Callable[[Self], Any], key: _KT) -> None: ...
class WeakKeyDictionary(MutableMapping[_KT, _VT]):
@overload

View file

@ -1 +1,7 @@
from pyexpat import *
# This is actually implemented in the C module pyexpat, but considers itself to live here.
class ExpatError(Exception):
code: int
lineno: int
offset: int

View file

@ -200,7 +200,7 @@ def dumps(
allow_none: bool = False,
) -> str: ...
def loads(
data: str, use_datetime: bool = False, use_builtin_types: bool = False
data: str | ReadableBuffer, use_datetime: bool = False, use_builtin_types: bool = False
) -> tuple[tuple[_Marshallable, ...], str | None]: ...
def gzip_encode(data: ReadableBuffer) -> bytes: ... # undocumented
def gzip_decode(data: ReadableBuffer, max_decode: int = 20971520) -> bytes: ... # undocumented

View file

@ -1,6 +1,7 @@
import http.server
import pydoc
import socketserver
from _typeshed import ReadableBuffer
from collections.abc import Callable, Iterable, Mapping
from re import Pattern
from typing import Any, ClassVar, Protocol
@ -48,8 +49,8 @@ class SimpleXMLRPCDispatcher: # undocumented
def register_multicall_functions(self) -> None: ...
def _marshaled_dispatch(
self,
data: str,
dispatch_method: Callable[[str | None, tuple[_Marshallable, ...]], Fault | tuple[_Marshallable, ...]] | None = None,
data: str | ReadableBuffer,
dispatch_method: Callable[[str, tuple[_Marshallable, ...]], Fault | tuple[_Marshallable, ...]] | None = None,
path: Any | None = None,
) -> str: ... # undocumented
def system_listMethods(self) -> list[str]: ... # undocumented

View file

@ -1,38 +1,35 @@
from _typeshed import StrPath
from collections.abc import Iterable, Sequence
import sys
from collections.abc import Iterable
from datetime import datetime, timedelta, tzinfo
from typing import Any, Protocol
from typing_extensions import Self
__all__ = ["ZoneInfo", "reset_tzpath", "available_timezones", "TZPATH", "ZoneInfoNotFoundError", "InvalidTZPathWarning"]
# TODO: remove this version check
# In theory we shouldn't need this version check. Pyright complains about the imports
# from zoneinfo.* when run on 3.8 and 3.7 without this. Updates to typeshed's
# pyright test script are probably needed, see #11189
if sys.version_info >= (3, 9):
from zoneinfo._common import ZoneInfoNotFoundError as ZoneInfoNotFoundError, _IOBytes
from zoneinfo._tzpath import (
TZPATH as TZPATH,
InvalidTZPathWarning as InvalidTZPathWarning,
available_timezones as available_timezones,
reset_tzpath as reset_tzpath,
)
class _IOBytes(Protocol):
def read(self, size: int, /) -> bytes: ...
def seek(self, size: int, whence: int = ..., /) -> Any: ...
__all__ = ["ZoneInfo", "reset_tzpath", "available_timezones", "TZPATH", "ZoneInfoNotFoundError", "InvalidTZPathWarning"]
class ZoneInfo(tzinfo):
@property
def key(self) -> str: ...
def __init__(self, key: str) -> None: ...
@classmethod
def no_cache(cls, key: str) -> Self: ...
@classmethod
def from_file(cls, fobj: _IOBytes, /, key: str | None = None) -> Self: ...
@classmethod
def clear_cache(cls, *, only_keys: Iterable[str] | None = None) -> None: ...
def tzname(self, dt: datetime | None, /) -> str | None: ...
def utcoffset(self, dt: datetime | None, /) -> timedelta | None: ...
def dst(self, dt: datetime | None, /) -> timedelta | None: ...
class ZoneInfo(tzinfo):
@property
def key(self) -> str: ...
def __init__(self, key: str) -> None: ...
@classmethod
def no_cache(cls, key: str) -> Self: ...
@classmethod
def from_file(cls, fobj: _IOBytes, /, key: str | None = None) -> Self: ...
@classmethod
def clear_cache(cls, *, only_keys: Iterable[str] | None = None) -> None: ...
def tzname(self, dt: datetime | None, /) -> str | None: ...
def utcoffset(self, dt: datetime | None, /) -> timedelta | None: ...
def dst(self, dt: datetime | None, /) -> timedelta | None: ...
# Note: Both here and in clear_cache, the types allow the use of `str` where
# a sequence of strings is required. This should be remedied if a solution
# to this typing bug is found: https://github.com/python/typing/issues/256
def reset_tzpath(to: Sequence[StrPath] | None = None) -> None: ...
def available_timezones() -> set[str]: ...
TZPATH: tuple[str, ...]
class ZoneInfoNotFoundError(KeyError): ...
class InvalidTZPathWarning(RuntimeWarning): ...
def __dir__() -> list[str]: ...
def __dir__() -> list[str]: ...

View file

@ -0,0 +1,13 @@
import io
from typing import Any, Protocol
class _IOBytes(Protocol):
def read(self, size: int, /) -> bytes: ...
def seek(self, size: int, whence: int = ..., /) -> Any: ...
def load_tzdata(key: str) -> io.BufferedReader: ...
def load_data(
fobj: _IOBytes,
) -> tuple[tuple[int, ...], tuple[int, ...], tuple[int, ...], tuple[int, ...], tuple[str, ...], bytes | None]: ...
class ZoneInfoNotFoundError(KeyError): ...

View file

@ -0,0 +1,13 @@
from _typeshed import StrPath
from collections.abc import Sequence
# Note: Both here and in clear_cache, the types allow the use of `str` where
# a sequence of strings is required. This should be remedied if a solution
# to this typing bug is found: https://github.com/python/typing/issues/256
def reset_tzpath(to: Sequence[StrPath] | None = None) -> None: ...
def find_tzfile(key: str) -> str | None: ...
def available_timezones() -> set[str]: ...
TZPATH: tuple[str, ...]
class InvalidTZPathWarning(RuntimeWarning): ...