docs: fix inaccuracies in README code examples#592
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #592 +/- ##
=======================================
Coverage 98.33% 98.33%
=======================================
Files 45 45
Lines 2157 2157
=======================================
Hits 2121 2121
Misses 36 36
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c1d480a to
f272731
Compare
There was a problem hiding this comment.
Code Review
This pull request updates the README documentation to align with recent SDK changes, including the transition from name-based to domain-based client initialization, method renames, and more precise type annotations for provider and hook implementations. The review feedback suggests further refining the hook example by importing FlagValueType and using it as a generic argument for FlagEvaluationDetails to ensure the documentation accurately reflects the SDK's actual method signatures.
f272731 to
20e3893
Compare
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
20e3893 to
02cd52c
Compare
There was a problem hiding this comment.
Pull request overview
Updates the README’s Python snippets to align with the actual openfeature Python SDK API, so examples can be copy‑pasted without import/runtime failures.
Changes:
- Fixes invalid/obsolete imports in the Targeting and Eventing examples (
get_providerremoval,EvaluationContext,EventDetails/ProviderEventcanonical module). - Corrects client acquisition and flag evaluation API usage in the Hooks example (
api.get_client(),get_boolean_value). - Aligns hook type annotations with the SDK’s hook interface (
HookHints,HookContext,FlagEvaluationDetails[FlagValueType]).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com> Signed-off-by: gruebel <anton.gruebel@gmail.com>
* test(e2e): add Behave step definitions for context merging Add the missing E2E step definitions so the contextMerging.feature scenarios from the OpenFeature spec run against python-sdk. Fixes #500 Changes: - Bump spec submodule to 130df3eb so contextMerging.feature is copied in during the `poe e2e` task. - Add tests/features/environment.py with a before_scenario hook that resets provider/hook/API-context/transaction-context state, so scenarios cannot leak state between features. - Add tests/features/steps/context_merging_steps.py: - RetrievableContextProvider captures the merged EvaluationContext it receives, so assertions can inspect what the SDK merged. - Step definitions for all scenarios in contextMerging.feature: single-level insert, multi-level insert, and per-key overwrite precedence across API / Transaction / Client / Invocation / Before Hooks. - Client-level context is set via direct attribute assignment on OpenFeatureClient.context (no new setter), since merging already honors client.context (openfeature/client.py:422-429). Runs clean: 4 features / 50 scenarios / 233 steps. Signed-off-by: gruebel <anton.gruebel@gmail.com> * docs: fix inaccuracies in README code examples (#592) Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com> Signed-off-by: gruebel <anton.gruebel@gmail.com> * fix: correctly reset api state on shutdown (#589) correctly reset api state on shutdown Signed-off-by: gruebel <anton.gruebel@gmail.com> * chore(main): release 0.9.0 (#555) Signed-off-by: OpenFeature Bot <109696520+openfeaturebot@users.noreply.github.com> Signed-off-by: gruebel <anton.gruebel@gmail.com> * chore(deps): update pre-commit hook tox-dev/pyproject-fmt to v2.21.2 (#601) * chore(deps): update pre-commit hook tox-dev/pyproject-fmt to v2.21.2 * upper bound toml-fmt-common till fixed Signed-off-by: gruebel <anton.gruebel@gmail.com> --------- Signed-off-by: gruebel <anton.gruebel@gmail.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: gruebel <anton.gruebel@gmail.com> Signed-off-by: gruebel <anton.gruebel@gmail.com> * chore(deps): update astral-sh/setup-uv action to v8 (#603) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Signed-off-by: gruebel <anton.gruebel@gmail.com> * chore(deps): update codecov/codecov-action action to v6 (#604) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Signed-off-by: gruebel <anton.gruebel@gmail.com> * chore(deps): update googleapis/release-please-action action to v5 (#605) * chore(deps): update googleapis/release-please-action action to v5 * fix config Signed-off-by: gruebel <anton.gruebel@gmail.com> --------- Signed-off-by: gruebel <anton.gruebel@gmail.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: gruebel <anton.gruebel@gmail.com> Signed-off-by: gruebel <anton.gruebel@gmail.com> * chore(deps): update pre-commit hook pre-commit/mirrors-mypy to v2 (#606) * chore(deps): update pre-commit hook pre-commit/mirrors-mypy to v2 * update config Signed-off-by: gruebel <anton.gruebel@gmail.com> --------- Signed-off-by: gruebel <anton.gruebel@gmail.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: gruebel <anton.gruebel@gmail.com> Signed-off-by: gruebel <anton.gruebel@gmail.com> * chore(deps): update dependency prek to >=0.4.3,<0.5.0 (#607) * chore(deps): update dependency prek to >=0.4.3,<0.5.0 * adjust CI Signed-off-by: gruebel <anton.gruebel@gmail.com> --------- Signed-off-by: gruebel <anton.gruebel@gmail.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: gruebel <anton.gruebel@gmail.com> Signed-off-by: gruebel <anton.gruebel@gmail.com> * feat!: make set_provider non-blocking, add set_provider_and_wait (#595) * feat!: make set_provider non-blocking, add set_provider_and_wait Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com> * fix: ruff format signature collapse in api.py Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com> * fix: use threading.Event in error event test to avoid flaky busy-wait Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com> * fixup: pr feedback and additional checks Signed-off-by: Todd Baert <todd.baert@dynatrace.com> * fix: check active registration in stale-init guard, not _provider_status Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com> * fixup: edge shutdown race Signed-off-by: Todd Baert <todd.baert@dynatrace.com> --------- Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com> Signed-off-by: Todd Baert <todd.baert@dynatrace.com> Co-authored-by: Todd Baert <todd.baert@dynatrace.com> Signed-off-by: gruebel <anton.gruebel@gmail.com> * fix: isolate provider event handler dispatch (#599) * Isolate provider event handlers Signed-off-by: Lucas-FManager <265058144+Lucas-FManager@users.noreply.github.com> * Address event handler review feedback Signed-off-by: Lucas-FManager <265058144+Lucas-FManager@users.noreply.github.com> * test: cover event dispatch noop path Signed-off-by: Lucas-FManager <265058144+Lucas-FManager@users.noreply.github.com> * fixup: drain executor at exit and relax non-blocking test timing margin Signed-off-by: Todd Baert <todd.baert@dynatrace.com> --------- Signed-off-by: Lucas-FManager <265058144+Lucas-FManager@users.noreply.github.com> Signed-off-by: Todd Baert <todd.baert@dynatrace.com> Co-authored-by: Lucas-FManager <265058144+Lucas-FManager@users.noreply.github.com> Co-authored-by: Todd Baert <todd.baert@dynatrace.com> Signed-off-by: gruebel <anton.gruebel@gmail.com> * test: fix flaky event handler test (#609) fix flaky event handler test Signed-off-by: gruebel <anton.gruebel@gmail.com> * chore(deps): update pre-commit hook astral-sh/ruff-pre-commit to v0.15.15 (#608) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Signed-off-by: gruebel <anton.gruebel@gmail.com> * chore(main): release 0.10.0 (#602) * chore(main): release 0.10.0 Signed-off-by: OpenFeature Bot <109696520+openfeaturebot@users.noreply.github.com> * docs: clarify non-blocking set_provider behavior in changelog Signed-off-by: Todd Baert <todd.baert@dynatrace.com> --------- Signed-off-by: OpenFeature Bot <109696520+openfeaturebot@users.noreply.github.com> Signed-off-by: Todd Baert <todd.baert@dynatrace.com> Co-authored-by: Todd Baert <todd.baert@dynatrace.com> Signed-off-by: gruebel <anton.gruebel@gmail.com> * fix CR comments Signed-off-by: gruebel <anton.gruebel@gmail.com> * cleanup Signed-off-by: gruebel <anton.gruebel@gmail.com> --------- Signed-off-by: gruebel <anton.gruebel@gmail.com> Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com> Signed-off-by: OpenFeature Bot <109696520+openfeaturebot@users.noreply.github.com> Signed-off-by: Todd Baert <todd.baert@dynatrace.com> Signed-off-by: Lucas-FManager <265058144+Lucas-FManager@users.noreply.github.com> Co-authored-by: Jonathan Norris <jonathan.norris@dynatrace.com> Co-authored-by: Anton Grübel <anton.gruebel@gmail.com> Co-authored-by: OpenFeature Bot <109696520+openfeaturebot@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Todd Baert <todd.baert@dynatrace.com> Co-authored-by: Nguyen Cat Luong <pkiphone.anhluong@gmail.com> Co-authored-by: Lucas-FManager <265058144+Lucas-FManager@users.noreply.github.com>
Summary
Changes
get_providerfromopenfeature.apiimports; added missingEvaluationContextimport fromopenfeature.evaluation_contextget_client(name="No-op Provider")toget_client(domain="No-op Provider")(actual parameter isdomain)client = OpenFeatureClient()(fails withTypeErrordue to requireddomainandversionargs) withapi.get_client()client.get_boolean_flag(...)toclient.get_boolean_value(...)(actual method name)ProviderEventimport to canonicalopenfeature.event; added missingEventDetailsimporthints: dicttohints: HookHints(actual type annotation); added missingHookContext,HookHints, andFlagEvaluationDetailsimportsAll fixed examples were verified to import and execute successfully against the current main branch.