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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Internal

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

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

### Fixed
Expand Down
14 changes: 6 additions & 8 deletions backoff/_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
def _ensure_coroutine(coro_or_func):
if inspect.iscoroutinefunction(coro_or_func):
return coro_or_func
else:

@functools.wraps(coro_or_func)
async def f(*args, **kwargs):
return coro_or_func(*args, **kwargs)
@functools.wraps(coro_or_func)
async def f(*args, **kwargs):
return coro_or_func(*args, **kwargs)

return f
return f


def _ensure_coroutines(coros_or_funcs):
Expand Down Expand Up @@ -108,9 +107,8 @@ async def retry(*args, **kwargs):
# <https://bugs.python.org/issue28613>
await asyncio.sleep(seconds)
continue
else:
await _call_handlers(on_success, **details, value=ret)
break
await _call_handlers(on_success, **details, value=ret)
break

return ret

Expand Down
5 changes: 2 additions & 3 deletions backoff/_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ def retry(*args, **kwargs):

time.sleep(seconds)
continue
else:
_call_handlers(on_success, **details, value=ret)
break
_call_handlers(on_success, **details, value=ret)
break

return ret

Expand Down
3 changes: 1 addition & 2 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ from sqlalchemy.exc import OperationalError, TimeoutError
)
def connect_to_database(connection_string):
engine = sqlalchemy.create_engine(connection_string)
connection = engine.connect()
return connection
return engine.connect()
```

### Transaction Retry with Deadlock Handling
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ docstring-code-line-length = 20

[tool.ruff.lint]
extend-select = [
"RET", # flake8-return
"SIM", # flake8-simplify
"UP", # pyupgrade
]
Expand Down
Loading