Voice et bot modif

This commit is contained in:
pi 2026-06-16 17:09:34 +00:00
parent 189d56026b
commit 7333a22bcd
10774 changed files with 634644 additions and 933308 deletions

View file

@ -2,23 +2,10 @@ import asyncio
import logging
import socket
from abc import ABC, abstractmethod
from collections.abc import Sized
from http.cookies import BaseCookie, Morsel
from typing import (
TYPE_CHECKING,
Any,
Awaitable,
Callable,
Dict,
Generator,
Iterable,
List,
Optional,
Sequence,
Tuple,
TypedDict,
Union,
)
from collections.abc import Awaitable, Callable, Generator, Iterable, Sequence, Sized
from http.cookies import BaseCookie, Morsel, SimpleCookie
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, TypedDict
from multidict import CIMultiDict
from yarl import URL
@ -32,8 +19,8 @@ if TYPE_CHECKING:
from .web_request import BaseRequest, Request
from .web_response import StreamResponse
else:
BaseRequest = Request = Application = StreamResponse = None
HTTPException = None
BaseRequest = Request = Application = StreamResponse = Any
HTTPException = Any
class AbstractRouter(ABC):
@ -74,21 +61,21 @@ class AbstractMatchInfo(ABC):
@abstractmethod
def expect_handler(
self,
) -> Callable[[Request], Awaitable[Optional[StreamResponse]]]:
) -> Callable[[Request], Awaitable[StreamResponse | None]]:
"""Expect handler for 100-continue processing"""
@property # pragma: no branch
@abstractmethod
def http_exception(self) -> Optional[HTTPException]:
def http_exception(self) -> HTTPException | None:
"""HTTPException instance raised on router's resolving, or None"""
@abstractmethod # pragma: no branch
def get_info(self) -> Dict[str, Any]:
def get_info(self) -> dict[str, Any]:
"""Return a dict with additional info useful for introspection"""
@property # pragma: no branch
@abstractmethod
def apps(self) -> Tuple[Application, ...]:
def apps(self) -> tuple[Application, ...]:
"""Stack of nested applications.
Top level application is left-most element.
@ -154,7 +141,7 @@ class AbstractResolver(ABC):
@abstractmethod
async def resolve(
self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET
) -> List[ResolveResult]:
) -> list[ResolveResult]:
"""Return IP address for given hostname"""
@abstractmethod
@ -174,16 +161,31 @@ ClearCookiePredicate = Callable[["Morsel[str]"], bool]
class AbstractCookieJar(Sized, IterableBase):
"""Abstract Cookie Jar."""
def __init__(self, *, loop: Optional[asyncio.AbstractEventLoop] = None) -> None:
def __init__(self, *, loop: asyncio.AbstractEventLoop | None = None) -> None:
self._loop = loop or asyncio.get_running_loop()
@property
@abstractmethod
def unsafe(self) -> bool:
"""Return True if cookies can be used with IP addresses."""
@property
@abstractmethod
def quote_cookie(self) -> bool:
"""Return True if cookies should be quoted."""
@property
@abstractmethod
def clear(self, predicate: Optional[ClearCookiePredicate] = None) -> None:
def cookies(self) -> MappingProxyType[tuple[str, str], SimpleCookie]:
"""Return the cookies stored in this jar."""
@property
@abstractmethod
def host_only_cookies(self) -> frozenset[tuple[str, str]]:
"""Return the host-only cookies stored in this jar."""
@abstractmethod
def clear(self, predicate: ClearCookiePredicate | None = None) -> None:
"""Clear all cookies if no predicate is passed."""
@abstractmethod
@ -211,10 +213,10 @@ class AbstractStreamWriter(ABC):
buffer_size: int = 0
output_size: int = 0
length: Optional[int] = 0
length: int | None = 0
@abstractmethod
async def write(self, chunk: Union[bytes, bytearray, memoryview]) -> None:
async def write(self, chunk: bytes | bytearray | memoryview) -> None:
"""Write chunk into stream."""
@abstractmethod
@ -227,7 +229,7 @@ class AbstractStreamWriter(ABC):
@abstractmethod
def enable_compression(
self, encoding: str = "deflate", strategy: Optional[int] = None
self, encoding: str = "deflate", strategy: int | None = None
) -> None:
"""Enable HTTP body compression"""