Metadata-Version: 2.5
Name: toggley
Version: 0.1.0
Summary: Toggley feature flags for Python servers: evaluates flags locally from a polled config.
Project-URL: Homepage, https://toggleyapp.com
Project-URL: Repository, https://github.com/albrightlabs/toggley-python
Project-URL: Issues, https://github.com/albrightlabs/toggley-python/issues
Author: Albright Labs
License-Expression: MIT
License-File: LICENSE
Keywords: feature flags,feature toggles,toggley
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# Toggley for Python

Feature flags from [Toggley](https://toggleyapp.com) for Python servers. The client downloads your environment's config, keeps it current in a background thread, and evaluates flags in your process. No network call per check, no dependencies, and user data never leaves your server.

```sh
pip install toggley
```

Python 3.10+.

```python
import os
import toggley

client = toggley.Client(server_key=os.environ["TOGGLEY_SERVER_KEY"])
client.wait_for_initialization(timeout=5)

context = {"key": str(user.id), "email": user.email, "plan": user.plan}

if client.bool_variation("new-checkout", context, False):
    ...

theme = client.string_variation("theme", context, "light")
```

Create one client per process and reuse it. Getters never raise: on any problem you get your default, and the `*_variation_detail` versions say why (`reason["kind"] == "ERROR"`, `reason["errorKind"]`).

| Method | |
|---|---|
| `bool_variation`, `string_variation`, `number_variation`, `json_variation`, `variation` | the value |
| `..._detail` | `{value, variation, reason, assignment, flagVersion}` |
| `all_flags(context)` | `{flag_key: value}` |
| `flush()`, `close()`, `with toggley.Client(...) as client:` | |

Options: `base_url` (default `https://my.toggleyapp.com`), `poll_interval` (30s), `timeout` (5s), `bootstrap` (config dict or JSON file path), `offline`, `events` (send evaluation counts every minute; counts only), `on_error`.

If Toggley can't be reached the client keeps serving the last config it received and retries with backoff. A rejected key stops polling.

Forking servers (gunicorn, uWSGI) are handled: the polling thread restarts in each worker. Counts are sent at exit.
