Skip to content

Commit 8dcdb7e

Browse files
docs: Fix invalid Python in the README context examples (#75)
**Requirements** - [ ] I have added test coverage for new or changed functionality - [x] I have followed the repository's [pull request submission guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests) - [x] I have validated my changes against all supported platform versions **Related issues** None. Found during the weekly OpenFeature provider audit. **Describe the solution you've provided** The `EvaluationContext` examples in "OpenFeature Specific Considerations" did not run as Python: they used `null`/`true`, `,` in place of `:` in dict entries, a `[ ... "anonymous" = > true ]` list for the user context, and a trailing `;`. The "private attributes in a multi-context" example also set `"kind": "organization"` rather than `"multi"`, so it described a single context with nested attributes instead of the multi-context the heading names. Each example now executes, and each one converts through `EvaluationContextConverter` to a valid LaunchDarkly context of the intended shape (checked against `openfeature-sdk` 0.10.0 and `launchdarkly-server-sdk` 9.20.0). **Describe alternatives you've considered** None. **Additional context** Docs only; no code changes. Link to Devin session: https://app.devin.ai/sessions/f7bc946afe8c41a28cf7f3f497fc8b9d Open in Devin Desktop: https://app.devin.ai/desktop/session/f7bc946afe8c41a28cf7f3f497fc8b9d?variant=devin [SDK-3496](https://launchdarkly.atlassian.net/browse/SDK-3496) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > **README-only fix** for the OpenFeature `EvaluationContext` examples under “OpenFeature Specific Considerations.” > > The snippets now use valid Python: dict entries use `:` instead of `,`, `None`/`True` replace `null`/`true`, trailing semicolons are removed, and nested `user`/`organization` blocks are dicts rather than malformed lists or `"anonymous" = > true` syntax. The **private attributes in a multi-context** example now sets `"kind": "multi"` (was `"organization"`) so it matches the section title and the intended multi-context shape. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d6e47f3. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> [SDK-3496]: https://launchdarkly.atlassian.net/browse/SDK-3496?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 3a48713 commit 8dcdb7e

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

‎README.md‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ context = EvaluationContext("the-key")
110110
#### A single context of kind "organization"
111111

112112
```python
113-
context = EvaluationContext("org-key", {"kind": "organization"});
113+
context = EvaluationContext("org-key", {"kind": "organization"})
114114
```
115115

116116
#### A multi-context containing a "user" and an "organization"
@@ -120,15 +120,15 @@ attributes = {
120120
"kind": "multi",
121121
"organization": {
122122
"name": "the-org-name",
123-
"targetingKey", "my-org-key",
124-
"myCustomAttribute", "myAttributeValue"
123+
"targetingKey": "my-org-key",
124+
"myCustomAttribute": "myAttributeValue",
125125
},
126126
"user": {
127127
"key": "my-user-key",
128-
"anonymous", true
129-
}
128+
"anonymous": True,
129+
},
130130
}
131-
context = EvaluationContext(null, attributes)
131+
context = EvaluationContext(None, attributes)
132132
```
133133

134134
#### Setting private attributes in a single context
@@ -147,7 +147,7 @@ context = EvaluationContext("org-key", attributes)
147147

148148
```python
149149
attributes = {
150-
"kind": "organization",
150+
"kind": "multi",
151151
"organization": {
152152
"name": "the-org-name",
153153
"targetingKey": "my-org-key",
@@ -156,15 +156,15 @@ attributes = {
156156
# This attribute will be private.
157157
"myCustomAttribute": "myAttributeValue",
158158
},
159-
"user": [
159+
"user": {
160160
"key": "my-user-key",
161-
"anonymous" = > true,
161+
"anonymous": True,
162162
# This attribute will not be private.
163163
"myCustomAttribute": "myAttributeValue",
164-
]
164+
},
165165
}
166166

167-
context = EvaluationContext(null, attributes)
167+
context = EvaluationContext(None, attributes)
168168
```
169169

170170
### Flag Metadata

0 commit comments

Comments
 (0)