fix(backend): 累积的错误修复和细节修正
This commit is contained in:
@@ -11,7 +11,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
CONFIG_PATH = Path.cwd() / ".nyahome" / "config.json"
|
||||
|
||||
T = TypeVar("T")
|
||||
T = TypeVar("T", str, int, bool, list)
|
||||
|
||||
|
||||
class ConfigManager:
|
||||
@@ -88,6 +88,10 @@ class ConfigManager:
|
||||
Args:
|
||||
key: 配置键名
|
||||
value: 配置键的新值,可以是(且仅支持)字符串、整型以及列表。
|
||||
|
||||
Raises:
|
||||
AttributeError: 配置键名错误
|
||||
TypeError: 配置键值类型错误
|
||||
"""
|
||||
try:
|
||||
old_value = self.get(key)
|
||||
@@ -102,7 +106,7 @@ class ConfigManager:
|
||||
case bool():
|
||||
new_value = bool(value)
|
||||
case list():
|
||||
new_value = [x for x in value]
|
||||
new_value = list(value)
|
||||
case _:
|
||||
raise TypeError(f"不支持 {type(old_value).__name__} 类型的设置项。({key})")
|
||||
setattr(self._config, key, new_value)
|
||||
@@ -114,6 +118,8 @@ class ConfigManager:
|
||||
Args:
|
||||
key: 配置键名
|
||||
|
||||
Raises:
|
||||
AttributeError: 配置键名错误
|
||||
"""
|
||||
ci = Config()
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user