From 769d7a6ced369acc7d2c409018e6a04984aacb36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= Date: Thu, 5 Feb 2026 00:18:37 -0600 Subject: [PATCH] Apply the Ruff `B` rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Edgar Ramírez Mondragón --- CHANGELOG.md | 2 ++ backoff/_async.py | 2 +- backoff/_sync.py | 2 +- pyproject.toml | 1 + tests/test_backoff.py | 2 +- tests/test_jitter.py | 2 +- tests/test_wait_gen.py | 2 +- 7 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99a41c6..5ad9ec7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ - Apply the Ruff `I` rules [#99](https://github.com/python-backoff/backoff/pull/99) (from [@edgarrmondragon](https://github.com/edgarrmondragon)) +- Apply the Ruff `B` rules [#100](https://github.com/python-backoff/backoff/pull/100) (from [@edgarrmondragon](https://github.com/edgarrmondragon)) + ## [v2.3.1] - 2025-12-18 ### Fixed diff --git a/backoff/_async.py b/backoff/_async.py index 9fc36d9..93a049c 100644 --- a/backoff/_async.py +++ b/backoff/_async.py @@ -177,7 +177,7 @@ async def retry(*args, **kwargs): seconds = _next_wait(wait, e, jitter, elapsed, max_time_value) except StopIteration: await _call_handlers(on_giveup, **details, exception=e) - raise e + raise e from None await _call_handlers(on_backoff, **details, wait=seconds, exception=e) diff --git a/backoff/_sync.py b/backoff/_sync.py index e06b1f1..b42774f 100644 --- a/backoff/_sync.py +++ b/backoff/_sync.py @@ -130,7 +130,7 @@ def retry(*args, **kwargs): seconds = _next_wait(wait, e, jitter, elapsed, max_time_value) except StopIteration: _call_handlers(on_giveup, **details, exception=e) - raise e + raise e from None _call_handlers(on_backoff, **details, wait=seconds, exception=e) diff --git a/pyproject.toml b/pyproject.toml index cfa70a9..5bf37a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -186,6 +186,7 @@ docstring-code-line-length = 20 [tool.ruff.lint] extend-select = [ "RET", # flake8-return + "B", # flake8-bugbear "I", # isort "SIM", # flake8-simplify "UP", # pyupgrade diff --git a/tests/test_backoff.py b/tests/test_backoff.py index 2db3d05..90b6c4f 100644 --- a/tests/test_backoff.py +++ b/tests/test_backoff.py @@ -939,7 +939,7 @@ def test_event_log_levels( backoff_log_count = 0 giveup_log_count = 0 - for logger_name, level, message in caplog.record_tuples: + for _logger_name, level, message in caplog.record_tuples: if level == backoff_log_level and backoff_re.match(message): backoff_log_count += 1 elif level == giveup_log_level and giveup_re.match(message): diff --git a/tests/test_jitter.py b/tests/test_jitter.py index 8193d0d..da103cb 100644 --- a/tests/test_jitter.py +++ b/tests/test_jitter.py @@ -3,7 +3,7 @@ def test_full_jitter(): for input in range(100): - for i in range(100): + for _i in range(100): jitter = backoff.full_jitter(input) assert jitter >= 0 assert jitter <= input diff --git a/tests/test_wait_gen.py b/tests/test_wait_gen.py index 33b1eec..a18fe62 100644 --- a/tests/test_wait_gen.py +++ b/tests/test_wait_gen.py @@ -94,7 +94,7 @@ def test_fibo_max_value(): def test_constant(): gen = backoff.constant(interval=3) gen.send(None) - for i in range(9): + for _i in range(9): assert next(gen) == 3