Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

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

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

## [v2.3.1] - 2025-12-18

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion backoff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from backoff._decorator import on_exception, on_predicate
from backoff._jitter import full_jitter, random_jitter
from backoff._wait_gen import constant, expo, fibo, runtime, decay
from backoff._wait_gen import constant, decay, expo, fibo, runtime

__all__ = [
"on_predicate",
Expand Down
1 change: 0 additions & 1 deletion backoff/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import traceback
import warnings


# Use module-specific logger with a default null handler.
_logger = logging.getLogger("backoff")
_logger.addHandler(logging.NullHandler()) # pragma: no cover
Expand Down
4 changes: 2 additions & 2 deletions backoff/_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import operator
from typing import Any, Callable, Iterable, Optional, Type, Union

from backoff import _async, _sync
from backoff._common import (
_prepare_logger,
_config_handlers,
_log_backoff,
_log_giveup,
_prepare_logger,
)
from backoff._jitter import full_jitter
from backoff import _async, _sync
from backoff._typing import (
_CallableT,
_Handler,
Expand Down
4 changes: 3 additions & 1 deletion docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ Real-world examples of using backoff in production.
### Basic API Retry

```python
import backoff
import requests

import backoff


@backoff.on_exception(
backoff.expo,
Expand Down Expand Up @@ -111,6 +112,7 @@ def execute_transaction(session, operation):

```python
import aiohttp

import backoff


Expand Down
3 changes: 2 additions & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ Backoff provides two main decorators:
Let's start with a simple example - retrying a network request:

```python
import backoff
import requests

import backoff


@backoff.on_exception(
backoff.expo,
Expand Down
3 changes: 2 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ pip install python-backoff
Basic retry on exception:

```python
import backoff
import requests

import backoff


@backoff.on_exception(
backoff.expo,
Expand Down
7 changes: 5 additions & 2 deletions docs/user-guide/async.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ Backoff fully supports Python's `async`/`await` syntax for asynchronous code.
Simply decorate async functions with the same decorators:

```python
import backoff
import aiohttp

import backoff


@backoff.on_exception(backoff.expo, aiohttp.ClientError)
async def fetch_data(url):
Expand Down Expand Up @@ -142,9 +143,11 @@ async def async_function():

```python
import asyncio
import logging

import aiohttp

import backoff
import logging

logger = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion docs/user-guide/decorators.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ The `on_exception` decorator retries a function when a specified exception is ra
### Basic Usage

```python
import backoff
import requests

import backoff


@backoff.on_exception(
backoff.expo,
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/event-handlers.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ def my_function():
### Structured Logging

```python
import logging
import json
import logging

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ logging.getLogger("backoff").addHandler(logging.StreamHandler())
### Structured Logging (JSON)

```python
import logging
import json
import logging


class JsonFormatter(logging.Formatter):
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ docstring-code-line-length = 20
[tool.ruff.lint]
extend-select = [
"RET", # flake8-return
"I", # isort
"SIM", # flake8-simplify
"UP", # pyupgrade
]
Expand Down
7 changes: 3 additions & 4 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
backoff patterns.
"""

import backoff


import requests
from requests import HTTPError
import responses
from requests import HTTPError

import backoff


@responses.activate
Expand Down
5 changes: 3 additions & 2 deletions tests/test_package.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import sys
from importlib.metadata import version

import backoff
from packaging.version import Version
from packaging.specifiers import SpecifierSet
from packaging.version import Version

import backoff

if sys.version_info >= (3, 11):
import tomllib
Expand Down
1 change: 0 additions & 1 deletion tests/test_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from backoff.types import Details


assert Details # type: ignore[truthy-function]
1 change: 0 additions & 1 deletion tests/test_typing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import backoff


# No pyunit tests are defined here yet, but the following decorator calls will
# be analyzed by mypy which would have caught a bug the last release.

Expand Down
3 changes: 2 additions & 1 deletion tests/test_wait_gen.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import backoff
import math

import backoff


def test_decay():
gen = backoff.decay()
Expand Down
Loading