PR Title Check / check-title (pull_request) Successful in 6s
Test Python Package / unit-tests (pull_request) Successful in 18s
Code Quality Pipeline / code-quality (pull_request) Successful in 1m28s
Test Python Package / integration-tests (pull_request) Failing after 1m54s
Test Python Package / coverage-report (pull_request) Has been skipped
Require buckets to exist by default on connect, extract env_bool parsing, and document local dev overrides for secure and auto-creation settings. Co-authored-by: Cursor <cursoragent@cursor.com>
22 lines
582 B
Python
22 lines
582 B
Python
"""Parse boolean values from environment variables."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
_TRUTHY = frozenset({"1", "true", "yes", "on"})
|
|
_FALSY = frozenset({"0", "false", "no", "off"})
|
|
|
|
|
|
def env_bool(name: str, default: bool) -> bool:
|
|
"""Parse an environment variable as a boolean value."""
|
|
raw = os.getenv(name)
|
|
if raw is None:
|
|
return default
|
|
normalized = raw.strip().lower()
|
|
if normalized in _TRUTHY:
|
|
return True
|
|
if normalized in _FALSY:
|
|
return False
|
|
raise ValueError(f"Invalid boolean value for {name}: {raw!r}")
|