from __future__ import annotations
import typing
from eggfetch.compat.httpx._auth import Auth, BasicAuth, DigestAuth, NetRCAuth
from eggfetch.compat.httpx._request import Request
if typing.TYPE_CHECKING:
from collections.abc import Generator
from eggfetch.compat.httpx._response import Response
class FunctionAuth(Auth):
def __init__(self, func: typing.Callable[[Request], Request]) -> None:
self._func = func
def auth_flow(self, request: Request) -> Generator[Request, Response, None]:
yield self._func(request)
def __repr__(self) -> str:
return f"FunctionAuth({self._func!r})"
__all__ = ["Auth", "BasicAuth", "DigestAuth", "FunctionAuth", "NetRCAuth"]