mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
Flags were natively supported in Rust (the hanzo-flags crate — the evaluation core, pub-exported for Rust callers and FFI-exported for the rest), Go (in-process via CGO to that core), and TypeScript (@hanzo/flags over /v1/flags). Python was the gap. This closes it. hanzo-flags POSTs an evaluation context to cloud /v1/flags — the same PostHog-compatible endpoint every other client speaks — and answers is_enabled / variant / payload from the response. It mirrors @hanzo/flags exactly: a HanzoFlags client bound to one host, load(distinct_id, person_properties=, groups=), the same three-field result, an async twin, and a one-shot evaluate(). Two invariants match the family: fail-open (a transport error yields the last good or empty result with errors_while_computing set, never a raise on the hot path) and cache-by-context+TTL. Zero runtime dependencies — stdlib urllib only, so a flag check never drags httpx/pydantic into a service. Tests stand up a local /v1/flags stub and prove the request shape is PostHog-compatible, the accessors resolve booleans/variants/payloads, the TTL cache holds, and both a 5xx and an unreachable host fail open. 7/7 green.
54 lines
1.6 KiB
TOML
54 lines
1.6 KiB
TOML
[project]
|
|
name = "hanzo-flags"
|
|
version = "0.1.0"
|
|
description = "Hanzo feature flags + A/B client — the Python side of the native flags engine (cloud /v1/flags), zero runtime deps, PostHog-compatible"
|
|
readme = "README.md"
|
|
license = { text = "MIT" }
|
|
requires-python = ">=3.9"
|
|
authors = [{ name = "Hanzo AI", email = "[email protected]" }]
|
|
keywords = ["feature-flags", "ab-testing", "posthog", "hanzo", "experiments"]
|
|
classifiers = [
|
|
"Development Status :: 4 - Beta",
|
|
"Intended Audience :: Developers",
|
|
"License :: OSI Approved :: MIT License",
|
|
"Operating System :: OS Independent",
|
|
"Programming Language :: Python :: 3.9",
|
|
"Programming Language :: Python :: 3.10",
|
|
"Programming Language :: Python :: 3.11",
|
|
"Programming Language :: Python :: 3.12",
|
|
"Programming Language :: Python :: 3.13",
|
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
"Typing :: Typed",
|
|
]
|
|
|
|
# Zero runtime dependencies — a flag check must never drag a dependency tree into
|
|
# a service. The client is stdlib urllib only.
|
|
dependencies = []
|
|
|
|
[project.optional-dependencies]
|
|
dev = ["pytest>=7.0.0", "ruff>=0.1.0", "mypy>=1.0.0"]
|
|
|
|
[project.urls]
|
|
Homepage = "https://hanzo.ai"
|
|
Documentation = "https://docs.hanzo.ai"
|
|
Repository = "https://github.com/hanzoai/python-sdk"
|
|
|
|
[build-system]
|
|
requires = ["hatchling"]
|
|
build-backend = "hatchling.build"
|
|
|
|
[tool.hatch.build.targets.wheel]
|
|
packages = ["hanzo_flags"]
|
|
|
|
[tool.ruff]
|
|
target-version = "py39"
|
|
line-length = 100
|
|
|
|
[tool.ruff.lint]
|
|
select = ["E", "W", "F", "I", "B", "C4", "UP"]
|
|
ignore = ["E501"]
|
|
|
|
[tool.mypy]
|
|
python_version = "3.9"
|
|
strict = true
|