diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 603b2f3..3f050e4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -53,11 +53,11 @@ repos: alias: ruff-format-docs args: ["--language", "python", "--no-pad-file", "--no-pad-groups", "--command", "ruff format", "docs/"] additional_dependencies: - - ruff==0.15.1 + - ruff==0.15.2 - id: doccmd name: Ruff check fix docs language: python alias: ruff-check-fix-docs args: ["--language", "python", "--no-pad-file", "--no-pad-groups", "--command", "ruff check --fix", "docs/"] additional_dependencies: - - ruff==0.15.1 + - ruff==0.15.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index cb3076c..7a00563 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Documentation + +- Fixed some examples [#116](https://github.com/python-backoff/backoff/pull/116) (from [@edgarrmondragon](https://github.com/edgarrmondragon)) + ### Internal - Apply the Ruff `RET` rules [#92](https://github.com/python-backoff/backoff/pull/92) (from [@edgarrmondragon](https://github.com/edgarrmondragon)) diff --git a/docs/examples.md b/docs/examples.md index 648b6d8..3b271b9 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -100,10 +100,11 @@ def execute_transaction(session, operation): try: result = operation(session) session.commit() - return result except Exception: session.rollback() raise + else: + return result ``` ## Async/Await @@ -266,7 +267,7 @@ logger = logging.getLogger(__name__) def log_retry(details): logger.warning( - "Backing off %s:%.1fs after %d tries calling %s", + "Backing off %.1fs after %d tries calling %s", details["wait"], details["tries"], details["target"].__name__, @@ -387,7 +388,7 @@ def check_circuit(e): ) def protected_api_call(url): if not circuit_breaker.should_attempt(): - raise Exception("Circuit breaker is open") + raise RuntimeError("Circuit breaker is open") return requests.get(url) ```