From 03f221a80791189c198febabc0c96cc494adae62 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Sun, 14 Jan 2024 03:41:40 +0100 Subject: [PATCH] misc: small formatting and error checking improvements --- worblehat/cli/main.py | 12 ++++++------ worblehat/services/config.py | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/worblehat/cli/main.py b/worblehat/cli/main.py index 7d107d4..f180351 100644 --- a/worblehat/cli/main.py +++ b/worblehat/cli/main.py @@ -1,8 +1,8 @@ from textwrap import dedent from sqlalchemy import ( - event, - select, + event, + select, ) from sqlalchemy.orm import Session @@ -191,10 +191,10 @@ class WorblehatCli(NumberedCmd): def do_exit(self, _: str): if self.sql_session_dirty: - if prompt_yes_no('Would you like to save your changes?'): - self.sql_session.commit() - else: - self.sql_session.rollback() + if prompt_yes_no('Would you like to save your changes?'): + self.sql_session.commit() + else: + self.sql_session.rollback() exit(0) diff --git a/worblehat/services/config.py b/worblehat/services/config.py index 384b472..5b4b199 100644 --- a/worblehat/services/config.py +++ b/worblehat/services/config.py @@ -24,6 +24,9 @@ class Config: ] def __class_getitem__(cls, name: str) -> Any: + if cls._config is None: + raise RuntimeError('Configuration not loaded, call Config.load_configuration() first.') + __config = cls._config for attr in name.split('.'): __config = __config.get(attr)