From c381947cebe81d092bc13c693afe4ec050eb2968 Mon Sep 17 00:00:00 2001 From: tgross03 Date: Sun, 8 Feb 2026 03:27:04 +0100 Subject: [PATCH 1/2] fix: Wrong types in config set CLI --- backpy/cli/config/set_command.py | 20 ++++++++++++++++++++ backpy/core/config/variables.py | 6 +++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/backpy/cli/config/set_command.py b/backpy/cli/config/set_command.py index e46ac24..abc4886 100644 --- a/backpy/cli/config/set_command.py +++ b/backpy/cli/config/set_command.py @@ -33,6 +33,26 @@ def set_value(key: str, value: str, force: bool, debug: bool) -> None: try: prev_value = VariableLibrary.get_variable(key=key) + if isinstance(prev_value, bool): + if value.lower() == "true": + value = True + elif value.lower() == "false": + value = False + else: + raise TypeError( + "The given value has to be boolean type (e.g. 'true' or 'false')!" + ) + elif isinstance(prev_value, int): + try: + value = int(value) + except ValueError: + raise TypeError("The given value has to be integer type (e.g. '1').") + elif isinstance(prev_value, float): + try: + value = float(value) + except ValueError: + raise TypeError("The given value has to be float type (e.g. '1.0').") + if prev_value == value: print( f"{palette.red}ERROR: {palette.maroon}The variable is already set " diff --git a/backpy/core/config/variables.py b/backpy/core/config/variables.py index 81b3b2a..5dfa87f 100644 --- a/backpy/core/config/variables.py +++ b/backpy/core/config/variables.py @@ -1,4 +1,5 @@ from pathlib import Path +from typing import Any from mergedeep import merge @@ -7,7 +8,6 @@ class VariableLibrary: - _instance = None def __new__(cls): @@ -73,12 +73,12 @@ def get_path(cls) -> Path: return instance._path @classmethod - def get_variable(cls, key: str): + def get_variable(cls, key: str) -> Any: instance = cls() return instance._config[key] @classmethod - def set_variable(cls, key: str, value: str) -> None: + def set_variable(cls, key: str, value: Any) -> None: instance = cls() instance._config[key] = value From 4dbc01bd54b1ee2f715c4c1bd776fc07376e8733 Mon Sep 17 00:00:00 2001 From: tgross03 Date: Fri, 27 Feb 2026 23:23:35 +0100 Subject: [PATCH 2/2] docs: Add changelog --- docs/changes/7.docs.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/changes/7.docs.rst diff --git a/docs/changes/7.docs.rst b/docs/changes/7.docs.rst new file mode 100644 index 0000000..749effb --- /dev/null +++ b/docs/changes/7.docs.rst @@ -0,0 +1 @@ +Prepared docs for usage by newly added modules.