From eefe1ec931eda52dbdde05b43ab212af9d422590 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 17 Aug 2026 10:34:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(config):=20=E6=9B=B4=E6=96=B0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=88=90=E5=8A=9F=E6=97=B6=E8=BF=94=E5=9B=9E=E7=A9=BA?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=B6=88=E6=81=AF=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=BF=9D=E5=AD=98=E8=AE=BE=E7=BD=AE=20500=20=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/runtime/config.py | 3 ++- tests/test_config_type_conversion.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/runtime/config.py b/app/runtime/config.py index e0ce5070e..9305ca3a4 100644 --- a/app/runtime/config.py +++ b/app/runtime/config.py @@ -907,7 +907,8 @@ class Settings(BaseSettings, ConfigModel, LogConfigModel): """ 更新 env 配置 """ - message = None + # 成功且无提示时使用空字符串,保证与 Tuple[bool, str] 返回类型一致 + message = "" is_converted = original_value is not None and str(original_value) != str( converted_value ) diff --git a/tests/test_config_type_conversion.py b/tests/test_config_type_conversion.py index 47df33d55..fa4713f58 100644 --- a/tests/test_config_type_conversion.py +++ b/tests/test_config_type_conversion.py @@ -11,14 +11,14 @@ def test_update_float_setting_accepts_json_integer(monkeypatch) -> None: field_name: str, original_value: Any, converted_value: Any, - ) -> tuple[bool, None]: + ) -> tuple[bool, str]: """记录待持久化配置,避免测试写入真实配置文件。""" persisted.update( field_name=field_name, original_value=original_value, converted_value=converted_value, ) - return True, None + return True, "" monkeypatch.setattr(settings, "LLM_TEMPERATURE", 0.3) monkeypatch.setattr( @@ -30,7 +30,7 @@ def test_update_float_setting_accepts_json_integer(monkeypatch) -> None: success, message = settings.update_setting("LLM_TEMPERATURE", 1) assert success is True - assert message is None + assert message == "" assert settings.LLM_TEMPERATURE == 1.0 assert isinstance(settings.LLM_TEMPERATURE, float) assert persisted == {