From 683c8b9740b9e717fc6dcc1ee5c0187fcac79098 Mon Sep 17 00:00:00 2001 From: CoderShady Date: Thu, 9 Apr 2026 17:18:27 +0530 Subject: [PATCH] Replace eval with TYPE_MAP for type conversion --- utils/settings.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/settings.py b/utils/settings.py index 6b8242b..51e529d 100755 --- a/utils/settings.py +++ b/utils/settings.py @@ -25,12 +25,15 @@ def check(value, checks, name): def get_check_value(key, default_result): return checks[key] if key in checks else default_result + TYPE_MAP = {"bool": bool, "int": int, "float": float, "str": str} + incorrect = False if value == {}: incorrect = True if not incorrect and "type" in checks: try: - value = eval(checks["type"])(value) # fixme remove eval + value = TYPE_MAP.get(checks["type"], str)(value) + except: incorrect = True @@ -78,7 +81,7 @@ def check(value, checks, name): + str(name) + "[#F7768E bold]=", extra_info=get_check_value("explanation", ""), - check_type=eval(get_check_value("type", "False")), # fixme remove eval + check_type=TYPE_MAP.get(get_check_value("type", ""), False), default=get_check_value("default", NotImplemented), match=get_check_value("regex", ""), err_message=get_check_value("input_error", "Incorrect input"),