OpenFeature Python Environment Variable Provider
Project description
A OpenFeature Python Environment Variable Provider
This provider loads flag values from environment variables.
If a flag with some key is evaluated when no env var named after this key exists, it will throw a FlagNotFoundError.
Otherwise it will attempt to parse the string value of the env var to the appropriate type (str,int,float, or object).
Errors during this parsing are forwarded to the user.
Installation
pip install openfeature-provider-env-var
Usage
Create a new instance of the EnvVarProvider:
provider = EnvVarProvider()
Configure the OpenFeature API to use the EnvVarProvider and retrieve the client:
from openfeature import api
from openfeature.contrib.provider.envvar import EnvVarProvider
api.set_provider(EnvVarProvider())
client = api.get_client()
result = client.get_boolean_value("<your feature flag key>", True)
The EnvVarProvider will attempt to read values from the present environment variables.
If no values is present for a flag key, it will throw a FlagNotFoundError.
Otherwise, it will attempt to parse the value associated with the key to the requested type (e.g. float in the case of
provider.resolve_float_details(key, 0.0, None)) and forward any error that is raised during parsing to the user.
Note that any such errors will be caught by the OpenFeature API and translated into appropriate error codes.
Build setup
This provider uses uv as build tool.
Building
uv build
Executing tests
uv run pytest
pre commit hooks
Install the pre commit hooks that ensure proper formatting:
uvx pre-commit install
License
Apache 2.0 - See LICENSE for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openfeature_provider_env_var-0.1.1.tar.gz.
File metadata
- Download URL: openfeature_provider_env_var-0.1.1.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d254aa221dd1585a645ee836919c1e00cc2a2e8b287018f3275e2efc895d093
|
|
| MD5 |
a066e0db53827d37b2beeb14ae1b470a
|
|
| BLAKE2b-256 |
72cc0d3c74178b1ea74f21af8c90ca9680e77dcc2b162b7d636990051431bd03
|
Provenance
The following attestation bundles were made for openfeature_provider_env_var-0.1.1.tar.gz:
Publisher:
release.yml on open-feature/python-sdk-contrib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openfeature_provider_env_var-0.1.1.tar.gz -
Subject digest:
6d254aa221dd1585a645ee836919c1e00cc2a2e8b287018f3275e2efc895d093 - Sigstore transparency entry: 1135460326
- Sigstore integration time:
-
Permalink:
open-feature/python-sdk-contrib@8592c28f70324836984e8697c03f95f3ca6ec815 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/open-feature
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8592c28f70324836984e8697c03f95f3ca6ec815 -
Trigger Event:
push
-
Statement type:
File details
Details for the file openfeature_provider_env_var-0.1.1-py3-none-any.whl.
File metadata
- Download URL: openfeature_provider_env_var-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96990a3784c2d2d9718942a3e85fb9574e5085f510686e7c9ff68f57c93c67a6
|
|
| MD5 |
f6094175ae07dc052174a7d6cee16beb
|
|
| BLAKE2b-256 |
20b77cdf90ee9f3085539e7ed8dfd0377a2db519638afc57f05baafbe0c86082
|
Provenance
The following attestation bundles were made for openfeature_provider_env_var-0.1.1-py3-none-any.whl:
Publisher:
release.yml on open-feature/python-sdk-contrib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openfeature_provider_env_var-0.1.1-py3-none-any.whl -
Subject digest:
96990a3784c2d2d9718942a3e85fb9574e5085f510686e7c9ff68f57c93c67a6 - Sigstore transparency entry: 1135460377
- Sigstore integration time:
-
Permalink:
open-feature/python-sdk-contrib@8592c28f70324836984e8697c03f95f3ca6ec815 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/open-feature
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8592c28f70324836984e8697c03f95f3ca6ec815 -
Trigger Event:
push
-
Statement type: