animedex.config.profile

Programmatic configuration object for animedex callers.

Config is the typed, immutable equivalent of the CLI’s flag stack. Every public API function in animedex accepts an optional config keyword argument and falls back to module-level defaults when not given. The CLI translates flags into a Config instance one-to-one and hands it off; downstream Python users construct a Config directly.

The fields here are deliberately a 1:1 mirror of the CLI flags defined in plans/03 §9 so that “what does this command do” and “what does this Python call do” stay in lock-step.

Config

class animedex.config.profile.Config(*, rate: Literal['normal', 'slow'] = 'normal', cache_ttl_seconds: int | None = None, no_cache: bool = False, source_attribution: bool = True, user_agent: str | None = None, timeout_seconds: float = 30.0, token_store: TokenStore | None = None)[source]

Bases: BaseModel

Frozen configuration object.

Variables:
  • rate (Literal["normal", "slow"]) – Voluntary rate-limit slowdown. "slow" halves the default refill rate; "normal" is the upstream- sanctioned default. We do not expose a faster mode because that would violate P1 caps.

  • cache_ttl_seconds (int or None) – Override for the per-row TTL applied to new cache entries. None means each call uses the default for its category.

  • no_cache (bool) – When True the call bypasses the cache for both reads and writes.

  • source_attribution (bool) – When True (the default) the JSON renderer includes _source on every field. The TTY renderer always shows the source column.

  • user_agent (str or None) – Override for the User-Agent string. None means the project default (animedex.transport.useragent.default_user_agent()).

  • timeout_seconds (float) – HTTP request timeout in seconds.

  • token_store (TokenStore or None) – Caller-supplied TokenStore. None means resolve lazily to a KeyringTokenStore on first use.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

rate: _RateLiteral
cache_ttl_seconds: int | None
no_cache: bool
source_attribution: bool
user_agent: str | None
timeout_seconds: float
token_store: TokenStore | None
effective_token_store() TokenStore[source]

Resolve token_store to a usable TokenStore.

Returns the explicitly-supplied store when one was passed, otherwise constructs a fresh KeyringTokenStore. The construction is deferred to call time so an environment without a real OS keyring backend does not break a code path that never actually needs credentials.

Returns:

A TokenStore ready for use.

Return type:

TokenStore

selftest

animedex.config.profile.selftest() bool[source]

Smoke-test the Config object.

Constructs the zero-arg default and a fully-populated instance, verifies the rate literal validation, and resolves the default token store; all of this stays in process memory.

Returns:

True on success.

Return type:

bool