Skip to content

Commit 8e985de

Browse files
Merge branch 'main' into monotonic
2 parents 91996b8 + b552afa commit 8e985de

File tree

8 files changed

+54
-13
lines changed

8 files changed

+54
-13
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
- "3.12"
3636
- "3.13"
3737
- "3.14"
38+
- "3.15"
3839
include:
3940
- os: ubuntu-22.04
4041
python-version: "3.7"
@@ -49,7 +50,7 @@ jobs:
4950
allow-prereleases: true
5051

5152
- name: Install uv
52-
uses: astral-sh/setup-uv@4959332f0f014c5280e7eac8b70c90cb574c9f9b # v6.6.0
53+
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v6.6.1
5354

5455
- name: Run tests
5556
run: uvx --with tox-gh --with tox-uv tox
@@ -79,7 +80,7 @@ jobs:
7980
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
8081

8182
- name: Install uv
82-
uses: astral-sh/setup-uv@4959332f0f014c5280e7eac8b70c90cb574c9f9b # v6.6.0
83+
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v6.6.1
8384

8485
- name: Combine coverage data and generate report
8586
run: uvx --with tox-uv tox -e coverage

.github/workflows/codeql-analysis.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ on:
1414
schedule:
1515
- cron: '0 5 * * 6'
1616

17+
permissions:
18+
actions: read
19+
contents: read
20+
security-events: write
21+
1722
jobs:
1823
analyze:
1924
name: Analyze
@@ -43,7 +48,7 @@ jobs:
4348

4449
# Initializes the CodeQL tools for scanning.
4550
- name: Initialize CodeQL
46-
uses: github/codeql-action/init@3c3833e0f8c1c83d449a7478aa59c036a9165498 # v3.29.11
51+
uses: github/codeql-action/init@2d92b76c45b91eb80fc44c74ce3fce0ee94e8f9d # v3.30.0
4752
with:
4853
languages: ${{ matrix.language }}
4954
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -54,7 +59,7 @@ jobs:
5459
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5560
# If this step fails, then you should remove it and run the build manually (see below)
5661
- name: Autobuild
57-
uses: github/codeql-action/autobuild@3c3833e0f8c1c83d449a7478aa59c036a9165498 # v3.29.11
62+
uses: github/codeql-action/autobuild@2d92b76c45b91eb80fc44c74ce3fce0ee94e8f9d # v3.30.0
5863

5964
# ℹ️ Command-line programs to run using the OS shell.
6065
# 📚 https://git.io/JvXDl
@@ -68,4 +73,4 @@ jobs:
6873
# make release
6974

7075
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@3c3833e0f8c1c83d449a7478aa59c036a9165498 # v3.29.11
76+
uses: github/codeql-action/analyze@2d92b76c45b91eb80fc44c74ce3fce0ee94e8f9d # v3.30.0

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ dist/
88
.cache/
99
*.egg-info
1010
.vscode
11-
.python-version
1211
.tox/
1312
coverage.xml

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.14

CHANGELOG.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22

33
## Unreleased
44

5-
- Adapt test cases to pytest-asyncio 1.0 compatibility https://github.com/python-backoff/backoff/pull/1 (from @pastalian)
5+
### Fixed
6+
67
- Use `inspect.iscoroutinefunction` instead of `asyncio.iscoroutinefunction` to avoid Python 3.14 deprecation warning https://github.com/python-backoff/backoff/pull/3 (from @edgarrmondragon)
7-
- Use uv for dependencies and packaging https://github.com/python-backoff/backoff/pull/7 (from @edgarrmondragon)
8+
- Adapt test cases to pytest-asyncio 1.0 compatibility https://github.com/python-backoff/backoff/pull/1 (from @pastalian)
89
- Include tests in source distribution https://github.com/python-backoff/backoff/pull/13 (from @edgarrmondragon)
10+
- Added `logging.LoggerAdapter` to `_MaybeLogger` union https://github.com/python-backoff/backoff/pull/34 (from @jcbertin)
11+
- Add `exception` to the typing-only `Details` dictionary for cases when `on_exception` is used https://github.com/python-backoff/backoff/pull/35
912
- Use `time.monotonic` instead of `datetime.datetime.now` https://github.com/python-backoff/backoff/pull/23 (from @luccabb)
1013

14+
### Packaging
15+
16+
- Use uv for dependencies and packaging https://github.com/python-backoff/backoff/pull/7 (from @edgarrmondragon)
17+
- Remove duplicate classifier https://github.com/python-backoff/backoff/pull/37 (from @edgarrmondragon)
18+
1119
## [v2.2.1] - 2022-10-05
1220

1321
- Fix type hint for wait generators https://github.com/litl/backoff/issues/177

backoff/_typing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class _Details(TypedDict):
2727
class Details(_Details, total=False):
2828
wait: float # present in the on_backoff handler case for either decorator
2929
value: Any # present in the on_predicate decorator case
30+
exception: Exception # present in the on_exception decorator case
3031

3132

3233
T = TypeVar("T")
@@ -38,7 +39,7 @@ class Details(_Details, total=False):
3839
]
3940
_Jitterer = Callable[[float], float]
4041
_MaybeCallable = Union[T, Callable[[], T]]
41-
_MaybeLogger = Union[str, logging.Logger, None]
42+
_MaybeLogger = Union[str, logging.Logger, logging.LoggerAdapter, None]
4243
_MaybeSequence = Union[T, Sequence[T]]
4344
_Predicate = Callable[[T], bool]
4445
_WaitGenerator = Callable[..., Generator[float, None, None]]

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ keywords = [
1515
classifiers = [
1616
"Development Status :: 5 - Production/Stable",
1717
"Intended Audience :: Developers",
18-
"Programming Language :: Python",
1918
"License :: OSI Approved :: MIT License",
2019
"Natural Language :: English",
2120
"Operating System :: OS Independent",
@@ -29,6 +28,7 @@ classifiers = [
2928
"Programming Language :: Python :: 3.12",
3029
"Programming Language :: Python :: 3.13",
3130
"Programming Language :: Python :: 3.14",
31+
"Programming Language :: Python :: 3.15",
3232
"Topic :: Internet :: WWW/HTTP",
3333
"Topic :: Software Development :: Libraries :: Python Modules",
3434
"Topic :: Utilities",
@@ -78,6 +78,7 @@ env_list = [
7878
"3.12",
7979
"3.13",
8080
"3.14",
81+
"3.15",
8182
"coverage",
8283
"lint",
8384
"typing",
@@ -101,6 +102,7 @@ depends = [
101102
"3.12",
102103
"3.13",
103104
"3.14",
105+
"3.15",
104106
]
105107
dependency_groups = [ "test" ]
106108
commands = [
@@ -138,6 +140,7 @@ commands = [
138140
]
139141

140142
[tool.tox.gh.python]
143+
"3.15" = ["3.15"]
141144
"3.14" = ["3.14", "lint", "typing"]
142145
"3.13" = ["3.13"]
143146
"3.12" = ["3.12"]

tests/test_backoff.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import pytest
1111

1212
import backoff
13+
from backoff._typing import Details
1314
from tests.common import _save_target
1415

1516

@@ -189,13 +190,35 @@ def test_on_exception_constant_iterable(monkeypatch):
189190
giveups = []
190191
successes = []
191192

193+
def on_backoff(details: Details):
194+
nonlocal backoffs
195+
assert details["tries"] == len(backoffs) + 1
196+
assert "exception" in details
197+
assert isinstance(details["exception"], KeyError)
198+
199+
backoffs.append(details)
200+
201+
def on_giveup(details: Details):
202+
nonlocal giveups
203+
assert details["tries"] == 4
204+
assert "exception" in details
205+
assert isinstance(details["exception"], KeyError)
206+
207+
giveups.append(details)
208+
209+
def on_success(details: Details):
210+
nonlocal successes
211+
212+
successes.append(details)
213+
214+
192215
@backoff.on_exception(
193216
backoff.constant,
194217
KeyError,
195218
interval=(1, 2, 3),
196-
on_backoff=backoffs.append,
197-
on_giveup=giveups.append,
198-
on_success=successes.append,
219+
on_backoff=on_backoff,
220+
on_giveup=on_giveup,
221+
on_success=on_success,
199222
)
200223
def endless_exceptions():
201224
raise KeyError('foo')

0 commit comments

Comments
 (0)