Module

config

Application configuration.

AppConfig is a frozen dataclass — immutable after creation, IDE-autocompletable, no string-key dict lookups.

Classes

AppConfig 86
Application configuration. Immutable after creation. All fields have sensible defaults. Override w…

Application configuration. Immutable after creation.

All fields have sensible defaults. Override what you need::

config = AppConfig(debug=True, port=3000, secret_key="s3cr3t")

Attributes

Name Type Description
host str
port int
debug bool
reload_include tuple[str, ...]
reload_dirs tuple[str, ...]
dev_browser_reload bool | None
secret_key str
allowed_hosts tuple[str, ...]
csp_nonce_enabled bool
strict_transport_security str | None
template_dir str | Path
component_dirs tuple[str | Path, ...]
extra_loaders tuple[Any, ...]
autoescape bool
trim_blocks bool
lstrip_blocks bool
strict_undefined bool
static_context MappingProxyType[str, Any] | dict[str, Any] | None
static_dir str | Path | None
static_url str
sse_heartbeat_interval float
sse_retry_ms int | None
sse_close_event str | None
suspense_error_template str | None
suspense_error_block str
mcp_path str
safe_target bool
sse_lifecycle bool
view_transitions bool | str
speculation_rules bool | str
delegation bool
alpine bool
alpine_version str
alpine_csp bool
islands bool
islands_version str
islands_contract_strict bool
max_content_length int
workers int
worker_mode str
metrics_enabled bool
metrics_path str
rate_limit_enabled bool
rate_limit_requests_per_second float
rate_limit_burst int
request_queue_enabled bool
request_queue_max_depth int
sentry_dsn str | None
sentry_environment str | None
sentry_release str | None
sentry_traces_sample_rate float
reload_timeout float
otel_endpoint str | None
otel_service_name str
websocket_compression bool
websocket_max_message_size int
lifecycle_logging bool
log_format str
log_level str
max_connections int
backlog int
keep_alive_timeout float
request_timeout float
ssl_certfile str | None
ssl_keyfile str | None
cache_backend str
cache_default_ttl int
cache_middleware_enabled bool
i18n_enabled bool
i18n_default_locale str
i18n_supported_locales tuple[str, ...]
i18n_directory str | Path
i18n_cookie_name str
i18n_url_prefix bool
env str
redis_url str | None
audit_sink str | None
feature_flags tuple[tuple[str, bool], ...]
http_timeout float
http_retries int
skip_contract_checks bool
lazy_pages bool
debug_fragment_validator bool

Methods

from_env 1 AppConfig
Load configuration from environment variables. Reads env vars with the given p…
classmethod
def from_env(cls, prefix: str = 'CHIRP_') -> AppConfig

Load configuration from environment variables.

Reads env vars with the given prefix (defaultCHIRP_). Unset vars use AppConfig defaults.

Ifpython-dotenv is installed (pip install chirp[config]), loads.envfrom the current directory before reading env.

Env vars (with CHIRP_ prefix): SECRET_KEY, DEBUG, ENV, HOST, PORT, ALLOWED_HOSTS, LOG_FORMAT (auto|text|json — forwarded to Pounce), SENTRY_DSN, SENTRY_ENVIRONMENT, SENTRY_RELEASE, REDIS_URL, AUDIT_SINK, SKIP_CONTRACT_CHECKS, LAZY_PAGES, HTTP_TIMEOUT, HTTP_RETRIES, FEATURE_=true|false (e.g. CHIRP_FEATURE_X=true)

Railway compatibility:

If CHIRP_PORT is unset, from_env() falls back to Railway's PORT.
If CHIRP_HOST is unset in a Railway environment, host defaults to
"0.0.0.0". If CHIRP_ALLOWED_HOSTS is unset and
RAILWAY_PUBLIC_DOMAIN is present, allowed_hosts includes that
domain and healthcheck.railway.app.
Parameters
Name Type Description
prefix Default:'CHIRP_'
Returns
AppConfig
feature 1 bool
Return True if the named feature flag is enabled.
def feature(self, name: str) -> bool
Parameters
Name Type Description
name
Returns
bool
Internal Methods 1
__post_init__ 0
def __post_init__(self) -> None

Functions

_env_int_first 2 int
Read the first present integer env var from *keys*.
def _env_int_first(keys: tuple[str, ...], default: int) -> int
Parameters
Name Type Description
keys tuple[str, ...]
default int
Returns
int
_env_allowed_hosts 1 tuple[str, ...]
Read allowed hosts, with Railway healthcheck support when detectable.
def _env_allowed_hosts(prefix: str) -> tuple[str, ...]
Parameters
Name Type Description
prefix str
Returns
tuple[str, ...]
_env_log_format 2 str
Read log format from env; invalid values fall back to default.
def _env_log_format(key: str, default: str) -> str
Parameters
Name Type Description
key str
default str
Returns
str
_levenshtein 2 int
Compute Levenshtein distance between two strings.
def _levenshtein(a: str, b: str) -> int
Parameters
Name Type Description
a str
b str
Returns
int
_warn_unknown_env_vars 2 None
Emit warnings for unrecognized env vars with the given prefix.
def _warn_unknown_env_vars(prefix: str, known_suffixes: frozenset[str]) -> None
Parameters
Name Type Description
prefix str
known_suffixes frozenset[str]