Skip to main content

Flipt Python

pypi

This directory contains the Python source code for the Flipt server-side client.

Documentation

API documentation is available at https://www.flipt.io/docs/reference/overview.

Installation

pip install flipt=={version}

Usage

In your Python code you can import this client and use it as so:

from flipt import FliptClient
from flipt.evaluation import BatchEvaluationRequest, EvaluationRequest

flipt_client = FliptClient()

variant_flag = flipt_client.evaluation.variant(
    EvaluationRequest(
        namespace_key="default",
        flag_key="flagll",
        entity_id="entity",
        context={"fizz": "buzz"},
    )
)

print(variant_flag)

There is a more detailed example in the examples directory.

Setting HTTP Headers

You can set custom HTTP headers for the client by using the headers parameter in the constructor.

flipt_client = FliptClient(headers={"X-Custom-Header": "Custom-Value"})

Flipt V2 Environment Support

Flipt V2 introduces the concept of environments. This client supports evaluation of flags in a specific environment by using the X-Flipt-Environment header.

flipt_client = FliptClient(headers={"X-Flipt-Environment": "production"})

Upgrading to 2.0

Version 2.0 replaces the httpx dependency with httpx2, Pydantic's maintained fork with the same API. The Flipt API surface does not change. These details do:

  • Transport errors such as connection refused, timeouts, and Transport Layer Security (TLS) failures are now httpx2 exceptions, for example httpx2.ConnectError and httpx2.TimeoutException. Update except clauses that name httpx exceptions to the httpx2 equivalents. flipt.exceptions.FliptApiError does not change.
  • The httpx_client argument of Evaluation, AsyncEvaluation, SyncFlag, and AsyncFlag must be an httpx2.Client or httpx2.AsyncClient.
  • flipt no longer installs httpx. If your project imports httpx directly, declare it yourself. httpx and httpx2 install side by side.
  • The client verifies TLS certificates against the trust store of your operating system instead of the certifi bundle. Private certificate authorities installed in that store work without extra configuration. SSL_CERT_FILE, SSL_CERT_DIR, and verify= on a custom client still work. In containers without operating system certificates, such as distroless images, set SSL_CERT_FILE to a certificate bundle.

For developers

After adding new code, please don't forget to add unit tests for new features. To format the code, check it with linters and run tests, use the make check command.

Please keep the Python PEP8 in mind while adding new code.

Metadata

Release files for flipt 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flipt 2.0.0
File Size Uploaded
flipt-2.0.0.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flipt 2.0.0
File Interpreter ABI Platform
flipt-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.6 kB

Release files / flipt-2.0.0.tar.gz

Download URL flipt-2.0.0.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e576920b3d98b579988c6bd83181e134c5b0edc9eabc0f9bfad8c831f5c9b641
BLAKE2b-256 checksum
How to use checksums
16ea8c4011aea19bb57145980ced6f7cf9e20d867b2d7751740d0b0a97f4c881
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.11.16 Linux/6.17.0-1022-azure

Release files / flipt-2.0.0-py3-none-any.whl

Download URL flipt-2.0.0-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
367df54efadebf0fa2703606fe1260646bddb4b427394f9f9625eafe0e1afdd3
BLAKE2b-256 checksum
How to use checksums
9ad55277cd2cf1711ea1b3041007ff65dcd35d6f3c1c4ebd8ce1c78d92fb6cc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.11.16 Linux/6.17.0-1022-azure
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page