Созданы stubs

This commit is contained in:
2025-10-26 14:19:34 +03:00
parent 15990c82df
commit e380eda03a
8 changed files with 110 additions and 1 deletions

View File

View File

@ -0,0 +1,31 @@
from types import TracebackType
from typing import Any, Self
import aiohttp
import httpx
from aiohttpx.responses import Response
EXCEPTIONS = ...
class AiohttpTransport(httpx.AsyncBaseTransport):
def __init__(
self, session: aiohttp.ClientSession | None = ...
) -> None: ...
def map_aiohttp_exception(
self, exc: Exception
) -> httpx.TimeoutException | httpx.HTTPError: ...
async def __aenter__(self) -> Self: ...
async def __aexit__(
self,
exc_type: type[BaseException] | None = ...,
exc_value: BaseException | None = ...,
traceback: TracebackType | None = ...,
) -> None: ...
async def aclose(self) -> None: ...
async def handle_async_request(
self, request: httpx.Request
) -> Response: ...
async def make_request(
self, method: str, url: str, headers: dict[str, Any], data: bytes
) -> Response: ...

View File

@ -0,0 +1,26 @@
from httpx import Request
from httpx import Response as HTTPXResponse
from httpx import _models as m # type: ignore
from aiohttpx.responses import Response
from aiohttpx.transports.rate_limiter import AsyncRateLimit, Redis
def generate_cache_key(request: Request) -> str: ...
def cache_response(
client: Redis[bytes],
cache_key: str,
request: Request,
response: Response | HTTPXResponse,
) -> None: ...
def get_ttl_from_headers(headers: m.Headers) -> int | None: ...
def get_cached_response(
client: Redis[bytes], cache_key: str
) -> Response | None: ...
def serialize_response(response: Response | HTTPXResponse) -> bytes: ...
def deserialize_response(serialized_response: bytes) -> Response: ...
class AsyncCacheTransport(AsyncRateLimit):
def __init__(
self, redis_url: str | None, key: str | None, limit: int | None
) -> None: ...
async def handle_async_request(self, request: Request) -> Response: ...

View File

@ -0,0 +1,12 @@
from httpx import Request
from redis import Redis
from aiohttpx.responses import Response
from aiohttpx.transports.aio import AiohttpTransport
class AsyncRateLimit(AiohttpTransport):
def __init__(
self, redis: Redis[bytes] | None, key: str | None, limit: int | None
) -> None: ...
async def request_is_limited(self) -> bool: ...
async def handle_async_request(self, request: Request) -> Response: ...