Skip to content

Commit fe649ed

Browse files
docs: Fixed some code examples
Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
1 parent dcfe8f9 commit fe649ed

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ repos:
5353
alias: ruff-format-docs
5454
args: ["--language", "python", "--no-pad-file", "--no-pad-groups", "--command", "ruff format", "docs/"]
5555
additional_dependencies:
56-
- ruff==0.15.1
56+
- ruff==0.15.2
5757
- id: doccmd
5858
name: Ruff check fix docs
5959
language: python
6060
alias: ruff-check-fix-docs
6161
args: ["--language", "python", "--no-pad-file", "--no-pad-groups", "--command", "ruff check --fix", "docs/"]
6262
additional_dependencies:
63-
- ruff==0.15.1
63+
- ruff==0.15.2

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Documentation
6+
7+
- Fixed some examples [#116](https://github.com/python-backoff/backoff/pull/116) (from [@edgarrmondragon](https://github.com/edgarrmondragon))
8+
59
### Internal
610

711
- Apply the Ruff `RET` rules [#92](https://github.com/python-backoff/backoff/pull/92) (from [@edgarrmondragon](https://github.com/edgarrmondragon))

docs/examples.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,11 @@ def execute_transaction(session, operation):
100100
try:
101101
result = operation(session)
102102
session.commit()
103-
return result
104103
except Exception:
105104
session.rollback()
106105
raise
106+
else:
107+
return result
107108
```
108109

109110
## Async/Await
@@ -266,7 +267,7 @@ logger = logging.getLogger(__name__)
266267

267268
def log_retry(details):
268269
logger.warning(
269-
"Backing off %s:%.1fs after %d tries calling %s",
270+
"Backing off %.1fs after %d tries calling %s",
270271
details["wait"],
271272
details["tries"],
272273
details["target"].__name__,
@@ -387,7 +388,7 @@ def check_circuit(e):
387388
)
388389
def protected_api_call(url):
389390
if not circuit_breaker.should_attempt():
390-
raise Exception("Circuit breaker is open")
391+
raise RuntimeError("Circuit breaker is open")
391392
return requests.get(url)
392393
```
393394

0 commit comments

Comments
 (0)