From 02a7e84833c0977c0d9b605578bc343c0705ccfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89loi=20Rivard?= Date: Thu, 14 Dec 2023 16:04:46 +0100 Subject: [PATCH] feat: raise an exception when toml is not installed and a configuration file is passed in the environment --- canaille/app/configuration.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/canaille/app/configuration.py b/canaille/app/configuration.py index afdc2c2a..c91b1e40 100644 --- a/canaille/app/configuration.py +++ b/canaille/app/configuration.py @@ -56,7 +56,9 @@ def setup_config(app, config=None, validate_config=True): ) if config: app.config.from_mapping(parse_file_keys(config)) - elif toml and "CONFIG" in os.environ: + elif "CONFIG" in os.environ: + if not toml: # pragma: no cover + raise Exception("toml library not installed. Cannot load configuration.") app.config.from_mapping(parse_file_keys(toml.load(os.environ.get("CONFIG")))) else: raise Exception(