from pydantic_settings import BaseSettings, SettingsConfigDict from pydantic import PositiveInt, computed_field, MySQLDsn from pydantic_core import Url import httpx class Configs(BaseSettings): DB_HOST: str DB_PORT: PositiveInt DB_NAME: str DB_LOGIN: str DB_PASSWORD: str HOST_DS: str PORT_DS: PositiveInt TOKEN_DS: str @computed_field def DB_URI(self) -> MySQLDsn: return Url( f"mysql+aiomysql://{self.DB_LOGIN}:{self.DB_PASSWORD}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_NAME}?charset=utf8mb4" ) @computed_field def DS_URL(self) -> httpx.URL: return httpx.URL( f"http://{self.HOST_DS}:{self.PORT_DS}/force-assign-role" ) model_config = SettingsConfigDict(env_file='.env', env_file_encoding='utf-8') configs = Configs()