diff --git a/app/config.py b/app/config.py index 472829c..07fa2a0 100644 --- a/app/config.py +++ b/app/config.py @@ -78,7 +78,17 @@ def _get_int_value(yaml_config: Optional[Dict[str, Any]], env_key: str, yaml_pat def _get_bool_value(yaml_config: Optional[Dict[str, Any]], env_key: str, yaml_path: List[str], default: bool) -> bool: """获取布尔配置值""" value = _get_config_value(yaml_config, env_key, yaml_path, str(default).lower()) - return value.lower() == "true" + + # 如果值已经是布尔类型,直接返回 + if isinstance(value, bool): + return value + + # 如果是字符串,转换为布尔值 + if isinstance(value, str): + return value.lower() == "true" + + # 其他类型转换为布尔值 + return bool(value) # 加载YAML配置