Skip to content

Commit

Permalink
Add parameters to generics in _client.py (#2266)
Browse files Browse the repository at this point in the history
Co-authored-by: Tom Christie <tom@tomchristie.com>
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
  • Loading branch information
3 people committed Oct 12, 2022
1 parent 36f1623 commit 71ee50b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions httpx/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ async def aclose(self) -> None:
await self._stream.aclose()


EventHook = typing.Callable[..., typing.Any]


class BaseClient:
def __init__(
self,
Expand All @@ -165,7 +168,7 @@ def __init__(
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,
Expand Down Expand Up @@ -236,12 +239,12 @@ def timeout(self, timeout: TimeoutTypes) -> None:
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", [])),
Expand Down Expand Up @@ -639,11 +642,11 @@ def __init__(
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",
):
Expand Down Expand Up @@ -712,7 +715,7 @@ def _init_transport(
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:
Expand Down Expand Up @@ -1360,11 +1363,11 @@ def __init__(
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",
):
Expand Down Expand Up @@ -1433,7 +1436,7 @@ def _init_transport(
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:
Expand Down

0 comments on commit 71ee50b

Please sign in to comment.