From b830f84ebeb8aa2b6eee83958712abd5449ae4a8 Mon Sep 17 00:00:00 2001 From: hygienic-books Date: Tue, 5 Jul 2022 19:03:21 +0200 Subject: [PATCH] feat(config): Add check if setting is incorrectly empty --- .../{{ cookiecutter.__project_slug }}.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/python-naive/{{ cookiecutter.__project_slug }}/{{ cookiecutter.__project_slug }}.py b/python-naive/{{ cookiecutter.__project_slug }}/{{ cookiecutter.__project_slug }}.py index 07440ed..65174b6 100644 --- a/python-naive/{{ cookiecutter.__project_slug }}/{{ cookiecutter.__project_slug }}.py +++ b/python-naive/{{ cookiecutter.__project_slug }}/{{ cookiecutter.__project_slug }}.py @@ -171,6 +171,21 @@ def is_same_as_default( return config_kv_pair in ini_defaults +def we_have_unset_options( + config_obj: configparser.ConfigParser(), + section_name: str) -> list: + + options_must_be_non_empty = [] + + for option in config_obj.options(section_name): + if not config_obj.get(section_name, option): + if option not in internal_empty_ok: + log.warning(f"In section '[{section_name}]' option '{option}' is empty, it mustn't be.") + options_must_be_non_empty.append(option) + + return options_must_be_non_empty + + def validate_config_sections( config_obj: configparser.ConfigParser()) -> None: for this_section in config_obj.sections():