Skip to content

settings

Main Tux configuration using Pydantic Settings.

This module provides the main configuration class and global instance, using the extracted models and proper pydantic-settings for environment variable binding.

Configuration loading priority (highest to lowest): 1. Environment variables 2. .env file 3. config.toml file 4. config.yaml file 5. config.json file 6. Default values

Classes:

  • Config

    Main Tux configuration using Pydantic Settings with multi-format support.

Functions:

Classes

Config

Bases: BaseSettings

Main Tux configuration using Pydantic Settings with multi-format support.

Configuration is loaded from multiple sources in priority order: 1. Environment variables (highest priority) 2. .env file 3. config.toml file 4. config.yaml file 5. config.json file 6. Default values (lowest priority)

Methods:

Attributes:

Attributes

database_url property
Python
database_url: str

Get database URL with proper host resolution.

NOTE: This is used for: - Production application (DatabaseService) - Integration tests (real PostgreSQL) - Alembic migrations

py-pglite unit tests do NOT use this URL - they create their own.

Functions

settings_customise_sources classmethod
Python
settings_customise_sources(
    settings_cls: type[BaseSettings],
    init_settings: PydanticBaseSettingsSource,
    env_settings: PydanticBaseSettingsSource,
    dotenv_settings: PydanticBaseSettingsSource,
    file_secret_settings: PydanticBaseSettingsSource,
) -> tuple[PydanticBaseSettingsSource, ...]

Customize settings sources to load from multiple file formats.

Priority order (highest to lowest): 1. Init settings (programmatic overrides) 2. Environment variables 3. .env file 4. config.toml file 5. config.yaml file 6. config.json file 7. File secret settings (Docker secrets, etc.)

Parameters:

Returns:

get_prefix
Python
get_prefix() -> str

Get command prefix for current environment.

Returns:

  • str

    The configured command prefix.

is_prefix_override_enabled
Python
is_prefix_override_enabled() -> bool

Check if prefix override is enabled by environment variable.

Returns True if BOT_INFO__PREFIX was explicitly set in environment variables, indicating the user wants to override all database prefix settings.

Returns:

  • bool

    True if prefix override is enabled, False otherwise.

is_debug_enabled
Python
is_debug_enabled() -> bool

Check if debug mode is enabled.

Returns:

  • bool

    True if debug mode is enabled, False otherwise.

get_cog_ignore_list
Python
get_cog_ignore_list() -> set[str]

Get cog ignore list for current environment.

Returns:

  • set[str]

    Set of cog names to ignore.

get_database_url
Python
get_database_url() -> str

Legacy method - use database_url property instead.

Returns:

  • str

    The database connection URL.

get_github_private_key
Python
get_github_private_key() -> str

Get the GitHub private key, handling base64 encoding if needed.

Returns:

  • str

    The decoded GitHub private key.

Functions

validate_environment

Python
validate_environment() -> None

Validate critical environment variables for security and correctness.

Raises:

  • ValueError

    If an insecure default password is used.