Fix config loading
This commit is contained in:
parent
e2257393a4
commit
7033a18a64
@ -1,5 +1,6 @@
|
||||
import os
|
||||
from typing import Annotated, Any, Generator, Self, cast
|
||||
from functools import cache
|
||||
from typing import Annotated, Any, Self, cast
|
||||
import logging
|
||||
|
||||
from pydantic import BaseModel, Field, model_validator
|
||||
@ -86,7 +87,8 @@ class _Config(BaseModel):
|
||||
component: _ComponentConfig
|
||||
|
||||
|
||||
def load_config() -> Generator[_Config]:
|
||||
@cache
|
||||
def load_config() -> _Config:
|
||||
"""
|
||||
Load the application config
|
||||
"""
|
||||
@ -111,7 +113,7 @@ def load_config() -> Generator[_Config]:
|
||||
with open(config.database.uri_file, "r", encoding="utf8") as f:
|
||||
config.database.uri_plain = f.read().strip().replace("\n", "")
|
||||
|
||||
yield config
|
||||
return config
|
||||
|
||||
|
||||
ConfigDep = Annotated[_Config, Depends(load_config)]
|
||||
|
Loading…
Reference in New Issue
Block a user