From c1ec445f30f50709ee3659243cb48e9bda70b85c Mon Sep 17 00:00:00 2001 From: Victor Westerhuis Date: Wed, 12 Feb 2025 11:10:10 +0100 Subject: [PATCH] Change return type annotation for Response.raise_for_status() to Self It always returns its self argument. This change makes subclasses easier to use. --- docs/api.md | 2 +- httpx/_models.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api.md b/docs/api.md index d01cc649ba..a55ea777fc 100644 --- a/docs/api.md +++ b/docs/api.md @@ -70,7 +70,7 @@ * The amount of time elapsed between sending the request and calling `close()` on the corresponding response received for that request. [total_seconds()](https://docs.python.org/3/library/datetime.html#datetime.timedelta.total_seconds) to correctly get the total elapsed seconds. -* `def .raise_for_status()` - **Response** +* `def .raise_for_status()` - **Self** * `def .json()` - **Any** * `def .read()` - **bytes** * `def .iter_raw([chunk_size])` - **bytes iterator** diff --git a/httpx/_models.py b/httpx/_models.py index 67d74bf86b..c365208968 100644 --- a/httpx/_models.py +++ b/httpx/_models.py @@ -791,7 +791,7 @@ def has_redirect_location(self) -> bool: and "Location" in self.headers ) - def raise_for_status(self) -> Response: + def raise_for_status(self) -> typing.Self: """ Raise the `HTTPStatusError` if one occurred. """