Coverage for src / local_deep_research / settings / base.py: 70%
30 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-02-25 01:07 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-02-25 01:07 +0000
1"""
2Base interface for settings management.
4This module defines the abstract base class that all settings managers
5must implement, ensuring a consistent interface.
6"""
8from abc import ABC, abstractmethod
9from typing import Any, Dict, Optional, Union
12class ISettingsManager(ABC):
13 """Abstract base class for settings managers."""
15 @abstractmethod
16 def get_setting(
17 self, key: str, default: Any = None, check_env: bool = True
18 ) -> Any:
19 """
20 Get a setting value.
22 Args:
23 key: Setting key
24 default: Default value if setting is not found
25 check_env: If true, check environment variables first
27 Returns:
28 Setting value or default if not found
29 """
30 pass
32 @abstractmethod
33 def set_setting(self, key: str, value: Any, commit: bool = True) -> bool:
34 """
35 Set a setting value.
37 Args:
38 key: Setting key
39 value: Setting value
40 commit: Whether to commit the change
42 Returns:
43 True if successful, False otherwise
44 """
45 pass
47 @abstractmethod
48 def get_all_settings(self) -> Dict[str, Any]:
49 """
50 Get all settings.
52 Returns:
53 Dictionary of all settings with metadata
54 """
55 pass
57 @abstractmethod
58 def create_or_update_setting(
59 self, setting: Union[Dict[str, Any], Any], commit: bool = True
60 ) -> Optional[Any]:
61 """
62 Create or update a setting.
64 Args:
65 setting: Setting object or dictionary
66 commit: Whether to commit the change
68 Returns:
69 The created or updated Setting model, or None if failed
70 """
71 pass
73 @abstractmethod
74 def delete_setting(self, key: str, commit: bool = True) -> bool:
75 """
76 Delete a setting.
78 Args:
79 key: Setting key
80 commit: Whether to commit the change
82 Returns:
83 True if successful, False otherwise
84 """
85 pass
87 @abstractmethod
88 def get_bool_setting(
89 self, key: str, default: bool = False, check_env: bool = True
90 ) -> bool:
91 """
92 Get a setting value as a boolean.
94 Args:
95 key: Setting key
96 default: Default boolean value if setting is not found
97 check_env: If true, check environment variables first
99 Returns:
100 Boolean value of the setting
101 """
102 pass
104 @abstractmethod
105 def get_settings_snapshot(self) -> Dict[str, Any]:
106 """
107 Get a simplified settings snapshot with just key-value pairs.
109 Returns:
110 Dictionary with setting keys mapped to their values
111 """
112 pass
114 @abstractmethod
115 def load_from_defaults_file(
116 self, commit: bool = True, **kwargs: Any
117 ) -> None:
118 """
119 Import settings from the defaults settings file.
121 Args:
122 commit: Whether to commit changes to database
123 **kwargs: Additional arguments for import_settings
124 """
125 pass
127 @abstractmethod
128 def import_settings(
129 self,
130 settings_data: Dict[str, Any],
131 commit: bool = True,
132 overwrite: bool = True,
133 delete_extra: bool = False,
134 ) -> None:
135 """
136 Import settings from a dictionary.
138 Args:
139 settings_data: The raw settings data to import
140 commit: Whether to commit the DB after loading
141 overwrite: If true, overwrite existing settings
142 delete_extra: If true, delete settings not in settings_data
143 """
144 pass