diff --git a/unwind/config.py b/unwind/config.py index 6cc255a..9e3a908 100644 --- a/unwind/config.py +++ b/unwind/config.py @@ -2,20 +2,20 @@ import os import tomllib from pathlib import Path -datadir = Path(os.getenv("UNWIND_DATA") or "./data") -cachedir = ( - Path(cachedir) - if (cachedir := os.getenv("UNWIND_CACHEDIR", datadir / ".cache")) - else None +datadir: Path = Path(os.getenv("UNWIND_DATA") or "./data") +cachedir: Path = Path(p) if (p := os.getenv("UNWIND_CACHEDIR")) else datadir / ".cache" +debug: bool = os.getenv("DEBUG") == "1" +loglevel: str = os.getenv("UNWIND_LOGLEVEL") or ("DEBUG" if debug else "INFO") +storage_path: Path = ( + Path(p) if (p := os.getenv("UNWIND_STORAGE")) else datadir / "db.sqlite" +) +config_path: Path = ( + Path(p) if (p := os.getenv("UNWIND_CONFIG")) else datadir / "config.toml" ) -debug = os.getenv("DEBUG") == "1" -loglevel = os.getenv("UNWIND_LOGLEVEL") or ("DEBUG" if debug else "INFO") -storage_path = os.getenv("UNWIND_STORAGE", datadir / "db.sqlite") -config_path = os.getenv("UNWIND_CONFIG", datadir / "config.toml") with open(config_path, "rb") as fd: _config = tomllib.load(fd) -api_base = _config["api"].get("base", "/api/") -api_cors = _config["api"].get("cors", "*") -api_credentials = _config["api"].get("credentials", {}) +api_base: str = _config["api"].get("base", "/api/") +api_cors: str = _config["api"].get("cors", "*") +api_credentials: dict[str, str] = _config["api"].get("credentials", {})