diff --git a/httpx/__init__.py b/httpx/__init__.py index 63225040ba..07fbf31b5b 100644 --- a/httpx/__init__.py +++ b/httpx/__init__.py @@ -1,3 +1,7 @@ +""" +A next-generation HTTP client for Python. +""" + from .__version__ import __description__, __title__, __version__ from ._api import * from ._auth import * diff --git a/httpx/_models.py b/httpx/_models.py index 2cc86321a4..278a099895 100644 --- a/httpx/_models.py +++ b/httpx/_models.py @@ -380,6 +380,19 @@ def __repr__(self) -> str: class Request: + """ + An HTTP request. + + Can be constructed explicitly for more control over exactly + what gets sent over the wire. + + ```python + >>> request = httpx.Request("GET", "https://example.org") + ``` + + The keyword arguments mirror those of `Client.build_request()`. + """ + def __init__( self, method: str, @@ -513,6 +526,19 @@ def __setstate__(self, state: dict[str, typing.Any]) -> None: class Response: + """ + An HTTP response. + + Returned by `Client` / `AsyncClient` requests or constructed + directly in tests and custom transports. + + ```python + >>> response = httpx.Response(200, json={"ok": True}) + >>> response.status_code + 200 + ``` + """ + def __init__( self, status_code: int, diff --git a/tests/test_exported_members.py b/tests/test_exported_members.py index 8d9c8a74ca..12e83cd3c2 100644 --- a/tests/test_exported_members.py +++ b/tests/test_exported_members.py @@ -11,3 +11,9 @@ def test_all_imports_are_exported() -> None: ), key=str.casefold, ) + + +def test_public_docstrings() -> None: + assert httpx.__doc__ and httpx.__doc__.strip() + assert httpx.Request.__doc__ and httpx.Request.__doc__.strip() + assert httpx.Response.__doc__ and httpx.Response.__doc__.strip()