Add exceptions missing from top-level package (#1045)
* Expose missing exceptions: CloseError, ConnectError, ReadError, WriteError * Lint
This commit is contained in:
parent
6cf9039593
commit
fab427972b
@ -4,6 +4,8 @@ from ._auth import Auth, BasicAuth, DigestAuth
|
||||
from ._client import AsyncClient, Client
|
||||
from ._config import PoolLimits, Proxy, Timeout
|
||||
from ._exceptions import (
|
||||
CloseError,
|
||||
ConnectError,
|
||||
ConnectTimeout,
|
||||
CookieConflict,
|
||||
DecodingError,
|
||||
@ -14,13 +16,17 @@ from ._exceptions import (
|
||||
PoolTimeout,
|
||||
ProtocolError,
|
||||
ProxyError,
|
||||
ReadError,
|
||||
ReadTimeout,
|
||||
RedirectError,
|
||||
RequestBodyUnavailable,
|
||||
RequestNotRead,
|
||||
ResponseClosed,
|
||||
ResponseNotRead,
|
||||
StreamConsumed,
|
||||
StreamError,
|
||||
TooManyRedirects,
|
||||
WriteError,
|
||||
WriteTimeout,
|
||||
)
|
||||
from ._models import URL, Cookies, Headers, QueryParams, Request, Response
|
||||
@ -54,6 +60,8 @@ __all__ = [
|
||||
"PoolLimits",
|
||||
"Proxy",
|
||||
"Timeout",
|
||||
"CloseError",
|
||||
"ConnectError",
|
||||
"ConnectTimeout",
|
||||
"CookieConflict",
|
||||
"DecodingError",
|
||||
@ -63,14 +71,18 @@ __all__ = [
|
||||
"NotRedirectResponse",
|
||||
"PoolTimeout",
|
||||
"ProtocolError",
|
||||
"ReadError",
|
||||
"ReadTimeout",
|
||||
"RedirectError",
|
||||
"RequestBodyUnavailable",
|
||||
"ResponseClosed",
|
||||
"ResponseNotRead",
|
||||
"RequestNotRead",
|
||||
"StreamConsumed",
|
||||
"StreamError",
|
||||
"ProxyError",
|
||||
"TooManyRedirects",
|
||||
"WriteError",
|
||||
"WriteTimeout",
|
||||
"URL",
|
||||
"URLLib3Transport",
|
||||
|
||||
21
tests/test_exceptions.py
Normal file
21
tests/test_exceptions.py
Normal file
@ -0,0 +1,21 @@
|
||||
import pytest
|
||||
|
||||
import httpx
|
||||
|
||||
|
||||
def test_httpx_exceptions_exposed() -> None:
|
||||
"""
|
||||
All exception classes defined in `httpx._exceptions`
|
||||
are exposed as public API.
|
||||
"""
|
||||
|
||||
not_exposed = [
|
||||
value
|
||||
for name, value in vars(httpx._exceptions).items()
|
||||
if isinstance(value, type)
|
||||
and issubclass(value, Exception)
|
||||
and not hasattr(httpx, name)
|
||||
]
|
||||
|
||||
if not_exposed:
|
||||
pytest.fail(f"Unexposed HTTPX exceptions: {not_exposed}")
|
||||
Loading…
Reference in New Issue
Block a user