Skip to content

Unleash/unleash-openfeature-python-provider

Repository files navigation

Unleash OpenFeature Python Provider

Python project scaffold managed with uv.

Prerequisites

  • Python 3.10+
  • uv

Install

uv add unleash-openfeature-python-provider

For local development, sync the project environment:

uv sync --dev

Test Harness

This repository includes the OpenFeature provider verifier as a git submodule. After cloning, initialize it before running the full test suite:

git submodule update --init --recursive

If the verifier submodule is intentionally updated, refresh it and commit the new submodule pointer:

git submodule update --remote --merge verifier
git status

Use

from openfeature import api
from openfeature.evaluation_context import EvaluationContext
from UnleashClient import UnleashClient

from unleash_openfeature_python_provider import UnleashFlagProvider

unleash_client = UnleashClient(
    url="https://app.unleash-hosted.com/demo/api",
    app_name="my-app",
    custom_headers={"Authorization": "<client-api-key>"},
)

api.set_provider_and_wait(UnleashFlagProvider(unleash_client))

client = api.get_client()
enabled = client.get_boolean_value(
    "my-feature",
    False,
    EvaluationContext(targeting_key="user-123"),
)

Example

uv run python examples/boolean_flag.py \
  --url https://app.unleash-hosted.com/demo/api \
  --api-key "$UNLEASH_API_KEY" \
  --flag-key my-feature \
  --targeting-key user-123

Build

uv build

Build artifacts are written to dist/.

Test

uv run pytest

Lint, Format, And Type Check

uv run ruff check
uv run ruff format
uv run basedpyright

About

Official Unleash Open Feature Python provider

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages