diff --git a/.gitignore b/.gitignore index a2690e6..933dd9f 100644 --- a/.gitignore +++ b/.gitignore @@ -161,4 +161,6 @@ cython_debug/ # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ -.vscode/ \ No newline at end of file +.vscode/ + +hack.py \ No newline at end of file diff --git a/README.md b/README.md index 36d64a6..2d21657 100644 --- a/README.md +++ b/README.md @@ -19,22 +19,21 @@ Several HTTP errors are often transient, and might succeed if retried: This project aims to simplify retrying these, by extending [`tenacity`](https://tenacity.readthedocs.io/) with custom retry and wait strategies, as well as a custom decorator. Defaults are sensible for most use cases, but are fully customizable. -Supports exceptions raised by both [`requests`](https://docs.python-requests.org/en/latest/index.html) and [`httpx`](https://python-httpx.org/). +Supports both [`requests`](https://docs.python-requests.org/en/latest/index.html) and [`httpx`](https://python-httpx.org/) natively, but could be customized to use with any library that raises exceptions for the conditions listed above. ## Install Install from PyPI: ```sh -# Supports both HTTPX and requests -pip install retryhttp +pip install retryhttp # Supports both HTTPX and requests ``` -You can also install support for only HTTPX or requests: +You can also install support for only HTTPX or requests, if you would rather not install unnecessary dependencies: ```sh -pip install retryhttp[httpx] # Supports only HTTPX -pip install retryhttp[requests] # Supports only requests +pip install retryhttp[httpx] # Supports only HTTPX +pip install retryhttp[requests] # Supports only requests ``` Or, install the latest development snapshot from git: @@ -49,8 +48,8 @@ pip install git+https://github.com/austind/retryhttp.git@develop import httpx from retryhttp import retry -# Retries retryable status codes (429, 500, 502, 503, 504), network errors, -# and timeouts, up to 3 times, with appropriate wait strategies for each +# Retries safely retryable status codes (429, 500, 502, 503, 504), network errors, +# and timeouts, up to a total of 3 times, with appropriate wait strategies for each # type of error. All of these behaviors are customizable. @retry def example(): @@ -62,4 +61,4 @@ def example(): ## Contributing -Contributions welcome! Open a discussion and let's chat about your idea. Looking forward to working with you! +Contributions welcome! Bug fixes and minor tweaks can jump straight to a [pull request](https://github.com/austind/retryhttp/compare). For more involved changes, [open an issue](https://github.com/austind/retryhttp/issues/new/choose) and let's chat about your idea. Thanks for your contribution! diff --git a/docs/changelog.md b/docs/changelog.md index cc6103c..66f2fde 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,9 @@ # Changelog +## v1.3.2 + +* Bugfix: Don't pass `stop`, `wait`, and `retry` keyword arguments from [`retryhttp.retry`][] on to `tenacity.retry()` ([#23](https://github.com/austind/retryhttp/issues/23)) + ## v1.3.1 * Fixed all outstanding mypy errors. ([#20](https://github.com/austind/retryhttp/issues/20) diff --git a/docs/guide.md b/docs/guide.md index 99ca254..817b63c 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -53,6 +53,9 @@ def get_example(): response.raise_for_status() ``` +!!! note + `retryhttp` works by catching exceptions, so your code must raise those exceptions. Most of the time, all you need is to call `response.raise_for_status()`. Be sure not to catch those exceptions in your own `try..except` block. + ## Advanced Usage You don't have to use the [`retryhttp.retry`][] decorator, which is provided purely for convenience. If you prefer, you can use [`tenacity.retry`](https://tenacity.readthedocs.io/en/latest/api.html#tenacity.retry) and roll your own approach. diff --git a/pyproject.toml b/pyproject.toml index e61465f..ce53186 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,16 +1,7 @@ -[build-system] -# Minimum requirements for the build system to execute. -# PEP 508 specifications for PEP 518. -# Banned setuptools versions have well-known issues -requires = [ - "setuptools >= 21.0.0,!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,!=36.2.0", # PSF/ZPL - "setuptools_scm[toml]>=3.4", -] -build-backend="setuptools.build_meta" [project] name = "retryhttp" -version = "1.3.1" +version = "1.3.2" description = "Retry potentially transient HTTP errors in Python." license = {file = "LICENSE"} readme = "README.md" @@ -75,11 +66,21 @@ Homepage = "https://github.com/austind/retryhttp" Repository = "https://github.com/austind/retryhttp.git" Issues = "https://github.com/austind/retryhttp/issues" +[build-system] +# Minimum requirements for the build system to execute. +# PEP 508 specifications for PEP 518. +# Banned setuptools versions have well-known issues +requires = [ + "setuptools >= 21.0.0,!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,!=36.2.0", # PSF/ZPL + "setuptools_scm[toml]>=3.4", +] +build-backend="setuptools.build_meta" + [tool.setuptools] packages = ["retryhttp"] [tool.ruff] -line-length = 88 +line-length = 100 indent-width = 4 target-version = "py38"