Test Python Package / unit-tests (pull_request) Successful in 12s
Code Quality Pipeline / code-quality (pull_request) Successful in 19s
PR Title Check / check-title (pull_request) Successful in 31s
Test Python Package / integration-tests (pull_request) Successful in 23s
Test Python Package / coverage-report (pull_request) Successful in 10s
Route Python hooks through uv run with versions pinned in uv.lock, add explicit Ruff settings, and extend the dependency bot to run pre-commit autoupdate. Co-authored-by: Cursor <[email protected]>
31 lines
692 B
Python
31 lines
692 B
Python
"""Redis connection configuration."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
import os
|
|
|
|
from python_utils import check_env
|
|
|
|
from python_repositories.config.dotenv_loader import load_dotenv
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class RedisConfig:
|
|
"""Configuration for connecting to Redis."""
|
|
|
|
uri: str
|
|
|
|
@classmethod
|
|
def from_env(
|
|
cls,
|
|
uri_env_var_name: str = "REDIS_URI",
|
|
*,
|
|
use_dotenv: bool = True,
|
|
) -> RedisConfig:
|
|
"""Load configuration from environment variables."""
|
|
if use_dotenv:
|
|
load_dotenv()
|
|
check_env(uri_env_var_name)
|
|
return cls(uri=str(os.getenv(uri_env_var_name)))
|