diff --git a/app/core/config.py b/app/core/config.py index 4180f59..28f9c59 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -1,3 +1,4 @@ +from pydantic import field_validator from pydantic_settings import BaseSettings, SettingsConfigDict @@ -25,6 +26,20 @@ class Settings(BaseSettings): model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore") + @field_validator( + "access_token_expire_minutes", + "hsts_max_age", + "editor_tip_max_length", + "highlights_max_length", + mode="before", + ) + @classmethod + def _parse_int_with_inline_comment(cls, value): + if isinstance(value, str): + cleaned = value.split("#", 1)[0].strip() + return int(cleaned) if cleaned else value + return value + @property def is_production(self) -> bool: return self.environment.lower() == "production"