Skip to content

Commit cd20c12

Browse files
committed
merge main and adapt code to follow 8f2caba
Signed-off-by: leohoare <[email protected]>
2 parents 72d69d5 + c2d1402 commit cd20c12

21 files changed

+328
-91
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646

4747
- if: matrix.python-version == '3.11'
4848
name: Upload coverage to Codecov
49-
uses: codecov/codecov-action@v5.1.2
49+
uses: codecov/codecov-action@v5.3.1
5050
with:
5151
flags: unittests # optional
5252
name: coverage # optional

.github/workflows/release.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ jobs:
2424
- uses: googleapis/release-please-action@v4
2525
id: release
2626
with:
27+
command: manifest
2728
token: ${{secrets.RELEASE_PLEASE_ACTION_TOKEN}}
28-
target-branch: main
29+
default-branch: main
30+
signoff: "OpenFeature Bot <[email protected]>"
2931
outputs:
3032
release_created: ${{ steps.release.outputs.release_created }}
3133
release_tag_name: ${{ steps.release.outputs.tag_name }}
@@ -37,12 +39,14 @@ jobs:
3739
# IMPORTANT: this permission is mandatory for trusted publishing to pypi
3840
id-token: write
3941
needs: release-please
40-
if: ${{ needs.release-please.outputs.release_created }}
41-
container:
42-
image: "python:3.13"
42+
if: ${{ fromJSON(needs.release-please.outputs.release_created || false) }}
4343

4444
steps:
45-
- uses: actions/checkout@v4
45+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
46+
47+
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5
48+
with:
49+
python-version: '3.13'
4650

4751
- name: Upgrade pip
4852
run: pip install --upgrade pip
@@ -54,5 +58,4 @@ jobs:
5458
run: hatch build
5559

5660
- name: Publish a Python distribution to PyPI
57-
# pinning till fixed https://github.com/pypa/gh-action-pypi-publish/issues/300
58-
uses: pypa/gh-action-pypi-publish@release/v1.11
61+
uses: pypa/gh-action-pypi-publish@release/v1

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "test-harness"]
2-
path = test-harness
3-
url = https://github.com/open-feature/test-harness.git
1+
[submodule "spec"]
2+
path = spec
3+
url = https://github.com/open-feature/spec.git

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
default_stages: [commit]
22
repos:
33
- repo: https://github.com/astral-sh/ruff-pre-commit
4-
rev: v0.9.1
4+
rev: v0.9.4
55
hooks:
66
- id: ruff
77
args: [--fix]

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{".":"0.7.4"}
1+
{".":"0.7.5"}

CHANGELOG.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,52 @@
11
# Changelog
22

3+
## [0.7.5](https://github.com/open-feature/python-sdk/compare/v0.7.4...v0.7.5) (2025-01-31)
4+
5+
6+
### ⚠ BREAKING CHANGES
7+
8+
The signature of the `finally_after` hook stage has been changed. The signature now includes the `evaluation details`, as per the [OpenFeature specification](https://openfeature.dev/specification/sections/hooks#requirement-438). To migrate, update any hook that implements the `finally_after` stage to accept `evaluation details` as the second argument.
9+
10+
* Add evaluation details to finally hook stage [#403](https://github.com/open-feature/python-sdk/issues/403) ([#423](https://github.com/open-feature/python-sdk/issues/423)) ([9e9bb5c](https://github.com/open-feature/python-sdk/commit/9e9bb5c6269cfa5d9c9ffc7141c6dc63e399cdca))
11+
12+
13+
### 🐛 Bug Fixes
14+
15+
* Finally hooks do not get called when the provider is not ready [#424](https://github.com/open-feature/python-sdk/issues/424) ([#425](https://github.com/open-feature/python-sdk/issues/425)) ([8f2caba](https://github.com/open-feature/python-sdk/commit/8f2cabaa32f595304ecd6964b6ae21909672ef4a))
16+
17+
18+
### ✨ New Features
19+
20+
* Add evaluation details to finally hook stage [#403](https://github.com/open-feature/python-sdk/issues/403) ([#423](https://github.com/open-feature/python-sdk/issues/423)) ([9e9bb5c](https://github.com/open-feature/python-sdk/commit/9e9bb5c6269cfa5d9c9ffc7141c6dc63e399cdca))
21+
* Update test harness (add assertions) [#1467](https://github.com/open-feature/python-sdk/issues/1467) ([#415](https://github.com/open-feature/python-sdk/issues/415)) ([f559d1b](https://github.com/open-feature/python-sdk/commit/f559d1b27a096c585bd81f32f6472039c9ce5e03))
22+
* Update test harness (copy test files) [#1467](https://github.com/open-feature/python-sdk/issues/1467) ([#416](https://github.com/open-feature/python-sdk/issues/416)) ([192f7c4](https://github.com/open-feature/python-sdk/commit/192f7c40bd07616030e86ff2aba7e993390d4af4))
23+
24+
25+
### 🧹 Chore
26+
27+
* **config:** migrate config renovate.json ([26bc964](https://github.com/open-feature/python-sdk/commit/26bc9642270f9371170ce8ab2d9b938a0fca187e))
28+
* **config:** migrate renovate config ([#408](https://github.com/open-feature/python-sdk/issues/408)) ([26bc964](https://github.com/open-feature/python-sdk/commit/26bc9642270f9371170ce8ab2d9b938a0fca187e))
29+
* **deps:** update actions/setup-python digest to 4237552 ([#422](https://github.com/open-feature/python-sdk/issues/422)) ([9c2ed71](https://github.com/open-feature/python-sdk/commit/9c2ed71c6efdc2ece9ae89cf91f3b019c44b0033))
30+
* **deps:** update codecov/codecov-action action to v5.1.0 ([#401](https://github.com/open-feature/python-sdk/issues/401)) ([0459330](https://github.com/open-feature/python-sdk/commit/0459330cb91e9b28a15bdd380aec4c56c3b5d8df))
31+
* **deps:** update codecov/codecov-action action to v5.1.1 ([#402](https://github.com/open-feature/python-sdk/issues/402)) ([a6907d6](https://github.com/open-feature/python-sdk/commit/a6907d610e6dde1eecef56f25f3cc6a569b6eee4))
32+
* **deps:** update codecov/codecov-action action to v5.1.2 ([#405](https://github.com/open-feature/python-sdk/issues/405)) ([1c56480](https://github.com/open-feature/python-sdk/commit/1c564804afad474151489d695af7fa0409a768c6))
33+
* **deps:** update codecov/codecov-action action to v5.2.0 ([#418](https://github.com/open-feature/python-sdk/issues/418)) ([b69e81a](https://github.com/open-feature/python-sdk/commit/b69e81a63676240ef2abb98e96d2954a50f0c20a))
34+
* **deps:** update codecov/codecov-action action to v5.3.0 ([#420](https://github.com/open-feature/python-sdk/issues/420)) ([6af37b1](https://github.com/open-feature/python-sdk/commit/6af37b1c2bc2e10161673af5726932129ed02506))
35+
* **deps:** update codecov/codecov-action action to v5.3.1 ([#421](https://github.com/open-feature/python-sdk/issues/421)) ([e99e481](https://github.com/open-feature/python-sdk/commit/e99e481524ccfbea5bc7554d531f9c883dce6b5f))
36+
* **deps:** update googleapis/release-please-action action to v4 ([#428](https://github.com/open-feature/python-sdk/issues/428)) ([99905d5](https://github.com/open-feature/python-sdk/commit/99905d57f8b21a640f8f64f177679eee127ebba6))
37+
* **deps:** update pre-commit hook astral-sh/ruff-pre-commit to v0.8.1 ([#398](https://github.com/open-feature/python-sdk/issues/398)) ([043385a](https://github.com/open-feature/python-sdk/commit/043385a8369e253a5e0ad1e184e980f8e8d7e5c7))
38+
* **deps:** update pre-commit hook astral-sh/ruff-pre-commit to v0.8.2 ([#400](https://github.com/open-feature/python-sdk/issues/400)) ([2b6e210](https://github.com/open-feature/python-sdk/commit/2b6e210bc9dda72335e646fc60cde79b5bdd76c1))
39+
* **deps:** update pre-commit hook astral-sh/ruff-pre-commit to v0.8.3 ([#404](https://github.com/open-feature/python-sdk/issues/404)) ([01ec388](https://github.com/open-feature/python-sdk/commit/01ec388d2d93fc87a4f2eca856cf507cbee35785))
40+
* **deps:** update pre-commit hook astral-sh/ruff-pre-commit to v0.8.4 ([#406](https://github.com/open-feature/python-sdk/issues/406)) ([3296d3b](https://github.com/open-feature/python-sdk/commit/3296d3b229d41c7f879adfb7ab36e19de36617e4))
41+
* **deps:** update pre-commit hook astral-sh/ruff-pre-commit to v0.8.6 ([#410](https://github.com/open-feature/python-sdk/issues/410)) ([7f9d422](https://github.com/open-feature/python-sdk/commit/7f9d422497a6d8392eee18ccfd12050eef7a2338))
42+
* **deps:** update pre-commit hook astral-sh/ruff-pre-commit to v0.9.0 ([#411](https://github.com/open-feature/python-sdk/issues/411)) ([bc6e333](https://github.com/open-feature/python-sdk/commit/bc6e3332157788ec3f8037f68b9087e26a4634b5))
43+
* **deps:** update pre-commit hook astral-sh/ruff-pre-commit to v0.9.1 ([#412](https://github.com/open-feature/python-sdk/issues/412)) ([cbace6a](https://github.com/open-feature/python-sdk/commit/cbace6a24c3fa091242aedd4f7c2e8de4332e463))
44+
* **deps:** update pre-commit hook astral-sh/ruff-pre-commit to v0.9.2 ([#414](https://github.com/open-feature/python-sdk/issues/414)) ([9304292](https://github.com/open-feature/python-sdk/commit/9304292ea91580cf8cbfee7dbde922caa818189d))
45+
* **deps:** update pre-commit hook astral-sh/ruff-pre-commit to v0.9.3 ([#419](https://github.com/open-feature/python-sdk/issues/419)) ([8f9cc7c](https://github.com/open-feature/python-sdk/commit/8f9cc7ca96a1210bab104e6342b4f7d1553bad3b))
46+
* **deps:** update pre-commit hook astral-sh/ruff-pre-commit to v0.9.4 ([#426](https://github.com/open-feature/python-sdk/issues/426)) ([f726706](https://github.com/open-feature/python-sdk/commit/f72670689d25b82c8d54cacde3b1af179e0bc7e6))
47+
* **deps:** update pre-commit hook pre-commit/mirrors-mypy to v1.14.0 ([#407](https://github.com/open-feature/python-sdk/issues/407)) ([89d6997](https://github.com/open-feature/python-sdk/commit/89d6997b1fe04df82e0873de7e7a1ea1aca2b071))
48+
* **deps:** update pre-commit hook pre-commit/mirrors-mypy to v1.14.1 ([#409](https://github.com/open-feature/python-sdk/issues/409)) ([2c1840c](https://github.com/open-feature/python-sdk/commit/2c1840c87d00177d87b93135a38a7df98a9f6c0b))
49+
350
## [0.7.4](https://github.com/open-feature/python-sdk/compare/v0.7.3...v0.7.4) (2024-11-25)
451

552

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
<!-- x-release-please-start-version -->
2121

22-
<a href="https://github.com/open-feature/python-sdk/releases/tag/v0.7.4">
23-
<img alt="Latest version" src="https://img.shields.io/static/v1?label=release&message=v0.7.4&color=blue&style=for-the-badge" />
22+
<a href="https://github.com/open-feature/python-sdk/releases/tag/v0.7.5">
23+
<img alt="Latest version" src="https://img.shields.io/static/v1?label=release&message=v0.7.5&color=blue&style=for-the-badge" />
2424
</a>
2525

2626
<!-- x-release-please-end -->
@@ -60,13 +60,13 @@
6060
#### Pip install
6161

6262
```bash
63-
pip install openfeature-sdk==0.7.4
63+
pip install openfeature-sdk==0.7.5
6464
```
6565

6666
#### requirements.txt
6767

6868
```bash
69-
openfeature-sdk==0.7.4
69+
openfeature-sdk==0.7.5
7070
```
7171

7272
```python

openfeature/client.py

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -547,21 +547,22 @@ async def evaluate_flag_details_async(
547547
flag_evaluation_options,
548548
)
549549
)
550-
error_code = self._assert_provider_status(
551-
flag_type,
552-
hook_context,
553-
reversed_merged_hooks,
554-
hook_hints,
555-
)
556-
if error_code:
557-
return FlagEvaluationDetails(
558-
flag_key=flag_key,
559-
value=default_value,
560-
reason=Reason.ERROR,
561-
error_code=error_code,
562-
)
563550

564551
try:
552+
error_code = self._assert_provider_status(
553+
flag_type,
554+
hook_context,
555+
reversed_merged_hooks,
556+
hook_hints,
557+
)
558+
if error_code:
559+
return FlagEvaluationDetails(
560+
flag_key=flag_key,
561+
value=default_value,
562+
reason=Reason.ERROR,
563+
error_code=error_code,
564+
)
565+
565566
merged_context = self._before_hooks_and_merge_context(
566567
flag_type,
567568
hook_context,
@@ -647,21 +648,22 @@ def evaluate_flag_details(
647648
flag_evaluation_options,
648649
)
649650
)
650-
error_code = self._assert_provider_status(
651-
flag_type,
652-
hook_context,
653-
reversed_merged_hooks,
654-
hook_hints,
655-
)
656-
if error_code:
657-
return FlagEvaluationDetails(
658-
flag_key=flag_key,
659-
value=default_value,
660-
reason=Reason.ERROR,
661-
error_code=error_code,
662-
)
663651

664652
try:
653+
error_code = self._assert_provider_status(
654+
flag_type,
655+
hook_context,
656+
reversed_merged_hooks,
657+
hook_hints,
658+
)
659+
if error_code:
660+
return FlagEvaluationDetails(
661+
flag_key=flag_key,
662+
value=default_value,
663+
reason=Reason.ERROR,
664+
error_code=error_code,
665+
)
666+
665667
merged_context = self._before_hooks_and_merge_context(
666668
flag_type,
667669
hook_context,
@@ -691,13 +693,14 @@ def evaluate_flag_details(
691693
except OpenFeatureError as err:
692694
error_hooks(flag_type, hook_context, err, reversed_merged_hooks, hook_hints)
693695

694-
return FlagEvaluationDetails(
696+
flag_evaluation = FlagEvaluationDetails(
695697
flag_key=flag_key,
696698
value=default_value,
697699
reason=Reason.ERROR,
698700
error_code=err.error_code,
699701
error_message=err.error_message,
700702
)
703+
return flag_evaluation
701704
# Catch any type of exception here since the user can provide any exception
702705
# in the error hooks
703706
except Exception as err: # pragma: no cover
@@ -708,16 +711,23 @@ def evaluate_flag_details(
708711
error_hooks(flag_type, hook_context, err, reversed_merged_hooks, hook_hints)
709712

710713
error_message = getattr(err, "error_message", str(err))
711-
return FlagEvaluationDetails(
714+
flag_evaluation = FlagEvaluationDetails(
712715
flag_key=flag_key,
713716
value=default_value,
714717
reason=Reason.ERROR,
715718
error_code=ErrorCode.GENERAL,
716719
error_message=error_message,
717720
)
721+
return flag_evaluation
718722

719723
finally:
720-
after_all_hooks(flag_type, hook_context, reversed_merged_hooks, hook_hints)
724+
after_all_hooks(
725+
flag_type,
726+
hook_context,
727+
flag_evaluation,
728+
reversed_merged_hooks,
729+
hook_hints,
730+
)
721731

722732
async def _create_provider_evaluation_async(
723733
self,

openfeature/hook/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,12 @@ def error(
109109
"""
110110
pass
111111

112-
def finally_after(self, hook_context: HookContext, hints: HookHints) -> None:
112+
def finally_after(
113+
self,
114+
hook_context: HookContext,
115+
details: FlagEvaluationDetails[typing.Any],
116+
hints: HookHints,
117+
) -> None:
113118
"""
114119
Run after flag evaluation, including any error processing.
115120
This will always run. Errors will be swallowed.

openfeature/hook/_hook_support.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ def error_hooks(
2525
def after_all_hooks(
2626
flag_type: FlagType,
2727
hook_context: HookContext,
28+
details: FlagEvaluationDetails[typing.Any],
2829
hooks: typing.List[Hook],
2930
hints: typing.Optional[HookHints] = None,
3031
) -> None:
31-
kwargs = {"hook_context": hook_context, "hints": hints}
32+
kwargs = {"hook_context": hook_context, "details": details, "hints": hints}
3233
_execute_hooks(
3334
flag_type=flag_type, hooks=hooks, hook_method=HookType.FINALLY_AFTER, **kwargs
3435
)

0 commit comments

Comments
 (0)