forked from petercarbsmith/ca-biositing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
24 lines (21 loc) · 833 Bytes
/
config.py
File metadata and controls
24 lines (21 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from functools import lru_cache
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
"""
Defines the application settings, loaded from environment variables.
"""
# This is the only setting our application code currently needs.
# Pydantic will automatically find this variable in the .env file.
DATABASE_URL: str
# Configure Pydantic to:
# 1. Look for a .env file.
# 2. Ignore extra variables found in the .env file (like POSTGRES_USER etc.)
# This resolves the ValidationError.
model_config = SettingsConfigDict(env_file=".env", extra='ignore')
@lru_cache()
def get_settings() -> Settings:
"""
Returns a cached instance of the Settings object.
Using lru_cache ensures the .env file is read only once.
"""
return Settings()