Coverage for src / local_deep_research / settings / base.py: 71%
24 statements
« prev ^ index » next coverage.py v7.12.0, created at 2026-01-11 00:51 +0000
« prev ^ index » next coverage.py v7.12.0, created at 2026-01-11 00:51 +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 load_from_defaults_file(
89 self, commit: bool = True, **kwargs: Any
90 ) -> None:
91 """
92 Import settings from the defaults settings file.
94 Args:
95 commit: Whether to commit changes to database
96 **kwargs: Additional arguments for import_settings
97 """
98 pass
100 @abstractmethod
101 def import_settings(
102 self,
103 settings_data: Dict[str, Any],
104 commit: bool = True,
105 overwrite: bool = True,
106 delete_extra: bool = False,
107 ) -> None:
108 """
109 Import settings from a dictionary.
111 Args:
112 settings_data: The raw settings data to import
113 commit: Whether to commit the DB after loading
114 overwrite: If true, overwrite existing settings
115 delete_extra: If true, delete settings not in settings_data
116 """
117 pass