Add parameters to generics in _client.py (#2266)
Co-authored-by: Tom Christie <tom@tomchristie.com> Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
This commit is contained in:
parent
36f16234bc
commit
71ee50b277
@ -153,6 +153,9 @@ class BoundAsyncStream(AsyncByteStream):
|
||||
await self._stream.aclose()
|
||||
|
||||
|
||||
EventHook = typing.Callable[..., typing.Any]
|
||||
|
||||
|
||||
class BaseClient:
|
||||
def __init__(
|
||||
self,
|
||||
@ -165,7 +168,7 @@ class BaseClient:
|
||||
follow_redirects: bool = False,
|
||||
max_redirects: int = DEFAULT_MAX_REDIRECTS,
|
||||
event_hooks: typing.Optional[
|
||||
typing.Mapping[str, typing.List[typing.Callable]]
|
||||
typing.Mapping[str, typing.List[EventHook]]
|
||||
] = None,
|
||||
base_url: URLTypes = "",
|
||||
trust_env: bool = True,
|
||||
@ -236,12 +239,12 @@ class BaseClient:
|
||||
self._timeout = Timeout(timeout)
|
||||
|
||||
@property
|
||||
def event_hooks(self) -> typing.Dict[str, typing.List[typing.Callable]]:
|
||||
def event_hooks(self) -> typing.Dict[str, typing.List[EventHook]]:
|
||||
return self._event_hooks
|
||||
|
||||
@event_hooks.setter
|
||||
def event_hooks(
|
||||
self, event_hooks: typing.Dict[str, typing.List[typing.Callable]]
|
||||
self, event_hooks: typing.Dict[str, typing.List[EventHook]]
|
||||
) -> None:
|
||||
self._event_hooks = {
|
||||
"request": list(event_hooks.get("request", [])),
|
||||
@ -639,11 +642,11 @@ class Client(BaseClient):
|
||||
limits: Limits = DEFAULT_LIMITS,
|
||||
max_redirects: int = DEFAULT_MAX_REDIRECTS,
|
||||
event_hooks: typing.Optional[
|
||||
typing.Mapping[str, typing.List[typing.Callable]]
|
||||
typing.Mapping[str, typing.List[EventHook]]
|
||||
] = None,
|
||||
base_url: URLTypes = "",
|
||||
transport: typing.Optional[BaseTransport] = None,
|
||||
app: typing.Optional[typing.Callable] = None,
|
||||
app: typing.Optional[typing.Callable[..., typing.Any]] = None,
|
||||
trust_env: bool = True,
|
||||
default_encoding: typing.Union[str, typing.Callable[[bytes], str]] = "utf-8",
|
||||
):
|
||||
@ -712,7 +715,7 @@ class Client(BaseClient):
|
||||
http2: bool = False,
|
||||
limits: Limits = DEFAULT_LIMITS,
|
||||
transport: typing.Optional[BaseTransport] = None,
|
||||
app: typing.Optional[typing.Callable] = None,
|
||||
app: typing.Optional[typing.Callable[..., typing.Any]] = None,
|
||||
trust_env: bool = True,
|
||||
) -> BaseTransport:
|
||||
if transport is not None:
|
||||
@ -1360,11 +1363,11 @@ class AsyncClient(BaseClient):
|
||||
limits: Limits = DEFAULT_LIMITS,
|
||||
max_redirects: int = DEFAULT_MAX_REDIRECTS,
|
||||
event_hooks: typing.Optional[
|
||||
typing.Mapping[str, typing.List[typing.Callable]]
|
||||
typing.Mapping[str, typing.List[typing.Callable[..., typing.Any]]]
|
||||
] = None,
|
||||
base_url: URLTypes = "",
|
||||
transport: typing.Optional[AsyncBaseTransport] = None,
|
||||
app: typing.Optional[typing.Callable] = None,
|
||||
app: typing.Optional[typing.Callable[..., typing.Any]] = None,
|
||||
trust_env: bool = True,
|
||||
default_encoding: typing.Union[str, typing.Callable[[bytes], str]] = "utf-8",
|
||||
):
|
||||
@ -1433,7 +1436,7 @@ class AsyncClient(BaseClient):
|
||||
http2: bool = False,
|
||||
limits: Limits = DEFAULT_LIMITS,
|
||||
transport: typing.Optional[AsyncBaseTransport] = None,
|
||||
app: typing.Optional[typing.Callable] = None,
|
||||
app: typing.Optional[typing.Callable[..., typing.Any]] = None,
|
||||
trust_env: bool = True,
|
||||
) -> AsyncBaseTransport:
|
||||
if transport is not None:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user