Skip to content

Commit f43490f

Browse files
committed
chore: add example to README.md
1 parent ee3caba commit f43490f

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,26 @@ provider = FlagsmithProvider(
5757
)
5858
```
5959

60-
The provider can then be used with the OpenFeature client as per
60+
The provider can then be used with the OpenFeature client as per
6161
[the documentation](https://openfeature.dev/docs/reference/concepts/evaluation-api#setting-a-provider).
6262

63+
### Evaluation Context
64+
65+
The evaluation context supports traits in two ways:
66+
1. Flat top-level attributes
67+
2. A nested traits object
68+
69+
The two forms are merged and sent to Flagsmith, with the traits object taking precedence if keys conflict.
70+
71+
```python
72+
context = EvaluationContext( # Traits are: {"abc":"def", "foo": "bar2"}
73+
targeting_key="user",
74+
attributes={
75+
"foo": "bar",
76+
"abc": "def",
77+
"traits": {"foo": "bar2"}
78+
},
79+
)
80+
81+
```
82+

0 commit comments

Comments
 (0)