Skip to content
Myr

Add exceptions missing from top-level package (#1045)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Expose missing exceptions: CloseError, ConnectError, ReadError, WriteError * Lint

authored by Florimond Manca · committed by GitHub · parent 6cf9039 · Browse files · 2 files+33 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+33 added−0 removed

  • tests:+21 added−0 removed
  • other:+12 added−0 removed

2 files+33 added−0 removed

modified:httpx/__init__.py+12 added
2 unmodified lines
3from ._auth import Auth, BasicAuth, DigestAuth4from ._client import AsyncClient, Client5from ._config import PoolLimits, Proxy, Timeout6from ._exceptions import (7 CloseError,8 ConnectError,9 ConnectTimeout,10 CookieConflict,11 DecodingError,12 HTTPError,
2 unmodified lines
15 NotRedirectResponse,16 PoolTimeout,17 ProtocolError,18 ProxyError,19 ReadError,20 ReadTimeout,21 RedirectError,22 RequestBodyUnavailable,23 RequestNotRead,24 ResponseClosed,25 ResponseNotRead,26 StreamConsumed,27 StreamError,28 TooManyRedirects,29 WriteError,30 WriteTimeout,31)32from ._models import URL, Cookies, Headers, QueryParams, Request, Response33from ._status_codes import StatusCode, codes
25 unmodified lines
59 "DigestAuth",60 "PoolLimits",61 "Proxy",62 "Timeout",63 "CloseError",64 "ConnectError",65 "ConnectTimeout",66 "CookieConflict",67 "DecodingError",68 "HTTPError",
1 unmodified line
70 "NetworkError",71 "NotRedirectResponse",72 "PoolTimeout",73 "ProtocolError",74 "ReadError",75 "ReadTimeout",76 "RedirectError",77 "RequestBodyUnavailable",78 "ResponseClosed",79 "ResponseNotRead",80 "RequestNotRead",81 "StreamConsumed",82 "StreamError",83 "ProxyError",84 "TooManyRedirects",85 "WriteError",86 "WriteTimeout",87 "URL",88 "URLLib3Transport",89 "URLLib3ProxyTransport",
10 unmodified lines
added:tests/test_exceptions.py+21 added
1import pytest23import httpx456def test_httpx_exceptions_exposed() -> None:7 """8 All exception classes defined in `httpx._exceptions`9 are exposed as public API.10 """1112 not_exposed = [13 value14 for name, value in vars(httpx._exceptions).items()15 if isinstance(value, type)16 and issubclass(value, Exception)17 and not hasattr(httpx, name)18 ]1920 if not_exposed:21 pytest.fail(f"Unexposed HTTPX exceptions: {not_exposed}")