from pydantic_settings import BaseSettings from pydantic import field_validator from functools import lru_cache class Settings(BaseSettings): frappe_url: str = "http://localhost:8000" frappe_api_key: str = "" frappe_api_secret: str = "" frappe_site_name: str = "" # optional: for multi-site Docker setups # Safety: set to True to block destructive operations read_only_mode: bool = False # Timeout for REST calls in seconds request_timeout: int = 30 @field_validator("frappe_url") @classmethod def strip_trailing_slash(cls, v: str) -> str: return v.rstrip("/") # Module activation — handled by module_registry, stored here so pydantic doesn't reject it enabled_modules: str = "" model_config = {"env_file": ".env", "env_file_encoding": "utf-8", "extra": "ignore"} @lru_cache def get_settings() -> Settings: return Settings()