From 83542eb10cf9dcddd0e6c08454f75110622b8cfd Mon Sep 17 00:00:00 2001 From: Mehmet BARUK Date: Wed, 25 Nov 2026 02:09:22 +0300 Subject: [PATCH 1/2] docs: add docstrings for httpx module, Request, and Response --- httpx/__init__.py | 4 ++++ httpx/_models.py | 26 ++++++++++++++++++++++++++ tests/test_exported_members.py | 5 +++++ 3 files changed, 35 insertions(+) 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..17ecf18e44 100644 --- a/tests/test_exported_members.py +++ b/tests/test_exported_members.py @@ -11,3 +11,8 @@ 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() From 9dbe02f62af30aa67b921102bd3309d3be89ca41 Mon Sep 17 00:00:00 2001 From: Mehmet BARUK Date: Wed, 25 Nov 2026 03:24:10 +0300 Subject: [PATCH 2/2] style: format tests/test_exported_members.py with ruff --- tests/test_exported_members.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_exported_members.py b/tests/test_exported_members.py index 17ecf18e44..12e83cd3c2 100644 --- a/tests/test_exported_members.py +++ b/tests/test_exported_members.py @@ -12,6 +12,7 @@ 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()