Созданы 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

@ -0,0 +1 @@
__version__: str = ...

33
stubs/aiohttpx/client.pyi Normal file
View File

@ -0,0 +1,33 @@
from collections.abc import Callable, Mapping
from ssl import SSLContext
from typing import Any
from httpx import URL, Limits
from httpx import AsyncClient as AsyncHTTPXClient
from httpx import _types as t # type: ignore
class AioHTTPXClient(AsyncHTTPXClient):
def __init__(
self,
*,
auth: t.AuthTypes | None = ...,
params: t.QueryParamTypes | None = ...,
headers: t.HeaderTypes | None = ...,
cookies: t.CookieTypes | None = ...,
verify: SSLContext | str | bool = ...,
cert: t.CertTypes | None = ...,
proxy: t.ProxyTypes | None = ...,
timeout: t.TimeoutTypes = ...,
follow_redirects: bool = ...,
limits: Limits = ...,
max_redirects: int = ...,
event_hooks: Mapping[str, list[Callable[..., Any]]] | None = ...,
base_url: URL | str = ...,
trust_env: bool = ...,
default_encoding: str | Callable[[bytes], str] = ...,
redis_url: str | None = ...,
key: str | None = ...,
limit: int | None = ...,
) -> None: ...
__all__ = ['AioHTTPXClient']

View File

@ -0,0 +1,6 @@
from typing import Any
from httpx import Response as HTTPXResponse
class Response(HTTPXResponse):
def json(self, **kwargs: Any) -> Any: ...

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: ...