pydantic-settings-manager 0.1.2__py3-none-any.whl → 0.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,17 +21,17 @@ from .base import BaseSettingsManager
21
21
  from .mapped import MappedSettingsManager, SettingsMap
22
22
  from .single import SingleSettingsManager
23
23
 
24
- __version__ = "0.1.0"
24
+ __version__ = "0.2.2"
25
25
 
26
26
  __all__ = [
27
27
  # Re-exports from pydantic_settings
28
28
  "BaseSettings",
29
- "SettingsConfigDict",
30
29
  # Base manager
31
30
  "BaseSettingsManager",
32
- # Single settings manager
33
- "SingleSettingsManager",
34
31
  # Mapped settings manager
35
32
  "MappedSettingsManager",
33
+ "SettingsConfigDict",
36
34
  "SettingsMap",
35
+ # Single settings manager
36
+ "SingleSettingsManager",
37
37
  ]
@@ -2,7 +2,7 @@
2
2
  Base classes for settings managers.
3
3
  """
4
4
  from abc import ABC, abstractmethod
5
- from typing import Any, Dict, Generic, Type, TypeVar
5
+ from typing import Any, Generic, TypeVar
6
6
 
7
7
  from pydantic_settings import BaseSettings
8
8
 
@@ -21,7 +21,7 @@ class BaseSettingsManager(ABC, Generic[T]):
21
21
  """
22
22
 
23
23
  @abstractmethod
24
- def __init__(self, settings_cls: Type[T]):
24
+ def __init__(self, settings_cls: type[T]):
25
25
  """
26
26
  Initialize the settings manager.
27
27
 
@@ -31,7 +31,7 @@ class BaseSettingsManager(ABC, Generic[T]):
31
31
  self.settings_cls = settings_cls
32
32
  """The settings class being managed"""
33
33
 
34
- self.user_config: Dict[str, Any] = {}
34
+ self.user_config: dict[str, Any] = {}
35
35
  """User configuration dictionary"""
36
36
 
37
37
  @property
@@ -3,7 +3,7 @@ Mapped settings manager implementation.
3
3
  """
4
4
  from __future__ import annotations
5
5
 
6
- from typing import Any, Dict, Generic, Type
6
+ from typing import Any, Generic
7
7
 
8
8
  from pydantic import BaseModel, Field
9
9
  from pydantic.main import create_model
@@ -30,7 +30,7 @@ class SettingsMap(BaseModel, Generic[T]):
30
30
  key: str = ""
31
31
  """The key of the currently active settings"""
32
32
 
33
- map: Dict[str, T] = Field(default_factory=dict)
33
+ map: dict[str, T] = Field(default_factory=dict)
34
34
  """A dictionary mapping keys to settings objects"""
35
35
 
36
36
 
@@ -80,20 +80,20 @@ class MappedSettingsManager(BaseSettingsManager[T]):
80
80
  ```
81
81
  """
82
82
 
83
- def __init__(self, settings_cls: Type[T]):
83
+ def __init__(self, settings_cls: type[T]):
84
84
  """
85
85
  Initialize the settings manager.
86
86
 
87
87
  Args:
88
88
  settings_cls: The settings class to manage
89
89
  """
90
- self.settings_cls: Type[T] = settings_cls
90
+ self.settings_cls: type[T] = settings_cls
91
91
  """The settings class being managed"""
92
92
 
93
93
  self.cli_args: SettingsMap[T] = SettingsMap[T]()
94
94
  """Command line arguments"""
95
95
 
96
- self.user_config: Dict[str, Any] = {}
96
+ self.user_config: dict[str, Any] = {}
97
97
  """User configuration"""
98
98
 
99
99
  self.system_settings: T = settings_cls()
@@ -128,7 +128,7 @@ class MappedSettingsManager(BaseSettingsManager[T]):
128
128
  self.clear()
129
129
 
130
130
  @property
131
- def _cli_args_config(self) -> Dict[str, Any]:
131
+ def _cli_args_config(self) -> dict[str, Any]:
132
132
  """
133
133
  Get the command line arguments as a dictionary.
134
134
 
@@ -146,7 +146,7 @@ class MappedSettingsManager(BaseSettingsManager[T]):
146
146
  return diff_dict(base, target)
147
147
 
148
148
  @property
149
- def _system_settings_config(self) -> Dict[str, Any]:
149
+ def _system_settings_config(self) -> dict[str, Any]:
150
150
  """
151
151
  Get the system settings as a dictionary.
152
152
 
@@ -180,7 +180,7 @@ class MappedSettingsManager(BaseSettingsManager[T]):
180
180
  DynamicMapSettings = create_model(
181
181
  "DynamicMapSettings",
182
182
  key=(str, ""),
183
- map=(Dict[str, self.settings_cls], {}), # type: ignore[name-defined]
183
+ map=(dict[str, self.settings_cls], {}), # type: ignore[name-defined]
184
184
  __base__=SettingsMap[T],
185
185
  )
186
186
 
@@ -215,7 +215,7 @@ class MappedSettingsManager(BaseSettingsManager[T]):
215
215
  if not self.map_settings.map:
216
216
  settings = self.settings_cls(**self.system_settings.model_dump())
217
217
  else:
218
- key = list(self.map_settings.map.keys())[0]
218
+ key = next(iter(self.map_settings.map.keys()))
219
219
  settings = self.map_settings.map[key]
220
220
  else:
221
221
  if self.map_settings.key not in self.map_settings.map:
@@ -272,7 +272,7 @@ class MappedSettingsManager(BaseSettingsManager[T]):
272
272
  return self.map_settings.key
273
273
 
274
274
  @property
275
- def all_settings(self) -> Dict[str, T]:
275
+ def all_settings(self) -> dict[str, T]:
276
276
  """
277
277
  Get all settings.
278
278
 
@@ -1,7 +1,7 @@
1
1
  """
2
2
  Single settings manager implementation.
3
3
  """
4
- from typing import Any, Dict, Type, Union
4
+ from typing import Any, Union
5
5
 
6
6
  from .base import BaseSettingsManager, T
7
7
  from .utils import NestedDict, nested_dict, update_dict
@@ -42,20 +42,20 @@ class SingleSettingsManager(BaseSettingsManager[T]):
42
42
  ```
43
43
  """
44
44
 
45
- def __init__(self, settings_cls: Type[T]):
45
+ def __init__(self, settings_cls: type[T]):
46
46
  """
47
47
  Initialize the settings manager.
48
48
 
49
49
  Args:
50
50
  settings_cls: The settings class to manage
51
51
  """
52
- self.settings_cls: Type[T] = settings_cls
52
+ self.settings_cls: type[T] = settings_cls
53
53
  """The settings class being managed"""
54
54
 
55
55
  self.cli_args: NestedDict = nested_dict()
56
56
  """Command line arguments"""
57
57
 
58
- self.user_config: Dict[str, Any] = {}
58
+ self.user_config: dict[str, Any] = {}
59
59
  """User configuration"""
60
60
 
61
61
  self._settings: Union[T, None] = None
@@ -1,6 +1,7 @@
1
- from typing import Any, DefaultDict, Union
1
+ from collections import defaultdict
2
+ from typing import Any, Union
2
3
 
3
- NestedDict = DefaultDict[str, Union["NestedDict", Any]]
4
+ NestedDict = defaultdict[str, Union["NestedDict", Any]]
4
5
  """
5
6
  ネストした辞書型
6
7
  """
@@ -2,12 +2,12 @@
2
2
  Utility functions for dictionary operations.
3
3
  """
4
4
  from collections import defaultdict
5
- from typing import Any, Dict
5
+ from typing import Any
6
6
 
7
7
  from .types import NestedDict
8
8
 
9
9
 
10
- def diff_dict(base: Dict[str, Any], target: Dict[str, Any]) -> Dict[str, Any]:
10
+ def diff_dict(base: dict[str, Any], target: dict[str, Any]) -> dict[str, Any]:
11
11
  """
12
12
  Get the difference between two dictionaries.
13
13
  Only includes keys where the values are different.
@@ -27,7 +27,7 @@ def diff_dict(base: Dict[str, Any], target: Dict[str, Any]) -> Dict[str, Any]:
27
27
  return result
28
28
 
29
29
 
30
- def update_dict(base: Dict[str, Any], update: Dict[str, Any]) -> Dict[str, Any]:
30
+ def update_dict(base: dict[str, Any], update: dict[str, Any]) -> dict[str, Any]:
31
31
  """
32
32
  Update a dictionary with another dictionary.
33
33
  Performs a deep update.
@@ -0,0 +1,372 @@
1
+ Metadata-Version: 2.4
2
+ Name: pydantic-settings-manager
3
+ Version: 0.2.2
4
+ Summary: A library for managing Pydantic settings objects
5
+ Project-URL: homepage, https://github.com/kiarina/pydantic-settings-manager
6
+ Project-URL: repository, https://github.com/kiarina/pydantic-settings-manager
7
+ Project-URL: documentation, https://github.com/kiarina/pydantic-settings-manager
8
+ Author-email: kiarina <kiarinadawa@gmail.com>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: configuration,pydantic,settings
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.9
23
+ Requires-Dist: pydantic-settings>=2.0.0
24
+ Requires-Dist: pydantic>=2.0.0
25
+ Description-Content-Type: text/markdown
26
+
27
+ # pydantic-settings-manager
28
+
29
+ A library for managing Pydantic settings objects.
30
+
31
+ ## Features
32
+
33
+ - Two types of settings managers:
34
+ - `SingleSettingsManager`: For managing a single settings object
35
+ - `MappedSettingsManager`: For managing multiple settings objects mapped to keys
36
+ - Support for loading settings from multiple sources
37
+ - Command line argument overrides
38
+ - Settings validation through Pydantic
39
+ - Type hints and documentation
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ pip install pydantic-settings-manager
45
+ ```
46
+
47
+ ## Quick Start
48
+
49
+ ### Basic Usage
50
+
51
+ Let's start with a simple example you can try immediately:
52
+
53
+ ```python
54
+ from pydantic_settings import BaseSettings
55
+ from pydantic_settings_manager import SingleSettingsManager
56
+
57
+ # 1. Define your settings
58
+ class AppSettings(BaseSettings):
59
+ app_name: str = "MyApp"
60
+ debug: bool = False
61
+ max_connections: int = 100
62
+
63
+ # 2. Create a settings manager
64
+ settings_manager = SingleSettingsManager(AppSettings)
65
+
66
+ # 3. Use your settings
67
+ settings = settings_manager.settings
68
+ print(f"App: {settings.app_name}, Debug: {settings.debug}")
69
+ ```
70
+
71
+ ### Loading from Configuration Files
72
+
73
+ You can load settings from external sources:
74
+
75
+ ```python
76
+ # Load from a dictionary (could be from JSON, YAML, etc.)
77
+ settings_manager.user_config = {
78
+ "app_name": "ProductionApp",
79
+ "debug": False,
80
+ "max_connections": 500
81
+ }
82
+
83
+ settings = settings_manager.settings
84
+ print(f"App: {settings.app_name}") # Output: App: ProductionApp
85
+ ```
86
+
87
+ ### Command Line Overrides
88
+
89
+ Override specific settings at runtime:
90
+
91
+ ```python
92
+ # Simulate command line arguments
93
+ settings_manager.cli_args["debug"] = True
94
+ settings_manager.cli_args["max_connections"] = 50
95
+
96
+ # Clear cache to apply changes
97
+ settings_manager.clear()
98
+
99
+ settings = settings_manager.settings
100
+ print(f"Debug: {settings.debug}") # Output: Debug: True
101
+ print(f"Connections: {settings.max_connections}") # Output: Connections: 50
102
+ ```
103
+
104
+ ### Multiple Configurations (Mapped Settings)
105
+
106
+ For managing multiple environments or configurations:
107
+
108
+ ```python
109
+ from pydantic_settings_manager import MappedSettingsManager
110
+
111
+ # Create a mapped settings manager
112
+ mapped_manager = MappedSettingsManager(AppSettings)
113
+
114
+ # Configure multiple environments
115
+ mapped_manager.user_config = {
116
+ "map": {
117
+ "development": {
118
+ "app_name": "MyApp-Dev",
119
+ "debug": True,
120
+ "max_connections": 10
121
+ },
122
+ "production": {
123
+ "app_name": "MyApp-Prod",
124
+ "debug": False,
125
+ "max_connections": 1000
126
+ }
127
+ }
128
+ }
129
+
130
+ # Switch between configurations
131
+ mapped_manager.set_cli_args("development")
132
+ dev_settings = mapped_manager.settings
133
+ print(f"Dev: {dev_settings.app_name}, Debug: {dev_settings.debug}")
134
+
135
+ mapped_manager.set_cli_args("production")
136
+ prod_settings = mapped_manager.settings
137
+ print(f"Prod: {prod_settings.app_name}, Debug: {prod_settings.debug}")
138
+ ```
139
+
140
+ ## Advanced Usage
141
+
142
+ ### Project Structure for Large Applications
143
+
144
+ For complex applications with multiple modules, you can organize your settings like this:
145
+
146
+ ```
147
+ your_project/
148
+ ├── hoge/
149
+ │ ├── __init__.py
150
+ │ ├── settings.py
151
+ │ ├── client.py
152
+ │ └── registry.py
153
+ ├── fuga/
154
+ │ ├── __init__.py
155
+ │ ├── settings.py
156
+ │ ├── client.py
157
+ │ └── registry.py
158
+ ├── bootstrap.py
159
+ ├── __main__.py
160
+ └── config.yaml
161
+ ```
162
+
163
+ ### Module-based Settings Management
164
+
165
+ ```python
166
+ # fuga/__init__.py
167
+ from .settings import settings_manager
168
+
169
+ __all__ = ["settings_manager"]
170
+ ```
171
+
172
+ ```python
173
+ # fuga/settings.py
174
+ from pydantic_settings import BaseSettings
175
+ from pydantic_settings_manager import MappedSettingsManager
176
+
177
+ class FugaSettings(BaseSettings):
178
+ name: str = "default"
179
+ api_key: str = "***"
180
+
181
+ settings_manager = MappedSettingsManager(FugaSettings)
182
+ ```
183
+
184
+ ```python
185
+ # fuga/client.py
186
+ from .settings import FugaSettings
187
+
188
+ class FugaClient:
189
+ def __init__(self, settings: FugaSettings):
190
+ self.settings = settings
191
+ ```
192
+
193
+ ```python
194
+ # fuga/registry.py
195
+ from .settings import settings_manager
196
+
197
+ def create_fuga_client(config_key: str = ""):
198
+ settings = settings_manager.get_settings_by_key(config_key)
199
+ return FugaClient(settings)
200
+ ```
201
+
202
+ ### Bootstrap
203
+
204
+ The bootstrap process loads configuration from external sources (like YAML files) and applies them to your settings managers. This allows you to centralize configuration management and easily switch between different environments.
205
+
206
+ ```yaml
207
+ # config.yaml
208
+ hoge:
209
+ name: "star"
210
+ value: 7
211
+ fuga:
212
+ key: first
213
+ map:
214
+ first:
215
+ name: "first"
216
+ api_key: "***"
217
+ second:
218
+ name: "second"
219
+ api_key: "***"
220
+ ```
221
+
222
+ ```python
223
+ # bootstrap.py
224
+ import importlib
225
+ import yaml
226
+
227
+ from pydantic_settings_manager import BaseSettingsManager
228
+
229
+ def bootstrap():
230
+ config = yaml.safe_load(open("/path/to/config.yaml"))
231
+
232
+ for module_name, user_config in config.items():
233
+ try:
234
+ module = importlib.import_module(module_name)
235
+ settings_manager = getattr(module, 'settings_manager', None)
236
+
237
+ if isinstance(settings_manager, BaseSettingsManager):
238
+ settings_manager.user_config = user_config
239
+ settings_manager.clear()
240
+ ```
241
+
242
+ ### CLI Integration
243
+
244
+ You can integrate command-line arguments to override specific settings at runtime. This is useful for debugging, testing different configurations, or providing runtime flexibility without modifying configuration files.
245
+
246
+ ```python
247
+ # __main__.py
248
+ import click
249
+
250
+ from .bootstrap import bootstrap
251
+ from .hoge import settings_manager as hoge_settings_manager
252
+ from .fuga import settings_manager as fuga_settings_manager
253
+
254
+ @click.command
255
+ @click.option("--name", type=str, default="", help="Name of the Hoge")
256
+ @click.option("--key", type=str, default="", help="Key for Fuga settings")
257
+ def main(name: str, key: str):
258
+ bootstrap()
259
+
260
+ if name:
261
+ hoge_settings_manager.cli_args["name"] = name
262
+ hoge_settings_manager.clear()
263
+
264
+ if key:
265
+ fuga_settings_manager.cli_args["key"] = key
266
+ fuga_settings_manager.clear()
267
+
268
+ # ...
269
+ ```
270
+
271
+ ## Related Tools
272
+
273
+ ### pydantic-config-builder
274
+
275
+ For complex projects with multiple configuration files, you might want to use [`pydantic-config-builder`](https://github.com/kiarina/pydantic-config-builder) to merge and build your YAML configuration files:
276
+
277
+ ```bash
278
+ pip install pydantic-config-builder
279
+ ```
280
+
281
+ This tool allows you to:
282
+ - Merge multiple YAML files into a single configuration
283
+ - Use base configurations with overlay files
284
+ - Build different configurations for different environments
285
+ - Support glob patterns and recursive merging
286
+
287
+ Example workflow:
288
+ ```yaml
289
+ # pydantic_config_builder.yml
290
+ development:
291
+ input:
292
+ - base/*.yaml
293
+ - dev-overrides.yaml
294
+ output:
295
+ - config/dev.yaml
296
+
297
+ production:
298
+ input:
299
+ - base/*.yaml
300
+ - prod-overrides.yaml
301
+ output:
302
+ - config/prod.yaml
303
+ ```
304
+
305
+ Then use the generated configurations with your settings manager:
306
+ ```python
307
+ import yaml
308
+ from your_app import settings_manager
309
+
310
+ # Load the built configuration
311
+ with open("config/dev.yaml") as f:
312
+ config = yaml.safe_load(f)
313
+
314
+ settings_manager.user_config = config
315
+ ```
316
+
317
+ ## Development
318
+
319
+ This project uses modern Python development tools with flexible dependency groups:
320
+
321
+ - **ruff**: Fast linter and formatter (replaces black, isort, and flake8)
322
+ - **mypy**: Static type checking
323
+ - **pytest**: Testing framework with coverage reporting
324
+ - **uv**: Fast Python package manager with PEP 735 dependency groups support
325
+
326
+ ### Setup
327
+
328
+ ```bash
329
+ # Install all development dependencies
330
+ uv sync --group dev
331
+
332
+ # Or install specific dependency groups
333
+ uv sync --group test # Testing tools only
334
+ uv sync --group lint # Linting tools only
335
+
336
+ # Format code
337
+ uv run ruff check --fix .
338
+
339
+ # Run linting
340
+ uv run ruff check .
341
+ uv run mypy .
342
+
343
+ # Run tests
344
+ uv run pytest --cov=pydantic_settings_manager tests/
345
+
346
+ # Build and test everything
347
+ make build
348
+ ```
349
+
350
+ ### Development Workflow
351
+
352
+ ```bash
353
+ # Quick setup for testing
354
+ uv sync --group test
355
+ make test
356
+
357
+ # Quick setup for linting
358
+ uv sync --group lint
359
+ make lint
360
+
361
+ # Full development environment
362
+ uv sync --group dev
363
+ make build
364
+ ```
365
+
366
+ ## Documentation
367
+
368
+ For more detailed documentation, please see the [GitHub repository](https://github.com/kiarina/pydantic-settings-manager).
369
+
370
+ ## License
371
+
372
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,11 @@
1
+ pydantic_settings_manager/__init__.py,sha256=eqe0IVD6o9FuoVR1xKqE0jyyhzd1u3yd77rnOe_9zQs,955
2
+ pydantic_settings_manager/base.py,sha256=k141GoasYGd-AoEo2qN86xWjW6StOuE1QhDqmEDP9XI,1258
3
+ pydantic_settings_manager/mapped.py,sha256=8O9tmh72_KgEWF5aIyXRsqiwsm2yUFfhxEmTkz9MfDM,7706
4
+ pydantic_settings_manager/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ pydantic_settings_manager/single.py,sha256=cuGzkLafDaTS_598148qKFTwVgNZjdhihgV7wiKiuBI,2759
6
+ pydantic_settings_manager/types.py,sha256=-LUZIr6g14nensFLgIs3CL4bxkcG7i7GlW3BmWHyub4,156
7
+ pydantic_settings_manager/utils.py,sha256=_DaEPdQjHFka_xlcC5E6e1QT0OAIymt6BL8RYIM_8Dg,1316
8
+ pydantic_settings_manager-0.2.2.dist-info/METADATA,sha256=A8vfiGLrV422FvqhwhLcHEgf7eVeudyhH8H_ZT_SVes,9410
9
+ pydantic_settings_manager-0.2.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
+ pydantic_settings_manager-0.2.2.dist-info/licenses/LICENSE,sha256=GtwfENGLMnpE6iSmuiVTC1AhFCLGvBYycR--RKNSs80,1060
11
+ pydantic_settings_manager-0.2.2.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.1
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,119 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: pydantic-settings-manager
3
- Version: 0.1.2
4
- Summary: A library for managing Pydantic settings objects
5
- Home-page: https://github.com/kiarina/pydantic-settings-manager
6
- License: MIT
7
- Keywords: pydantic,settings,configuration
8
- Author: kiarina
9
- Author-email: kiarinadawa@gmail.com
10
- Requires-Python: >=3.8,<4.0
11
- Classifier: Development Status :: 4 - Beta
12
- Classifier: Intended Audience :: Developers
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Operating System :: OS Independent
15
- Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.8
17
- Classifier: Programming Language :: Python :: 3.9
18
- Classifier: Programming Language :: Python :: 3.10
19
- Classifier: Programming Language :: Python :: 3.11
20
- Classifier: Programming Language :: Python :: 3.12
21
- Classifier: Programming Language :: Python :: 3.13
22
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
- Requires-Dist: pydantic (>=2.0.0,<3.0.0)
24
- Requires-Dist: pydantic-settings (>=2.0.0,<3.0.0)
25
- Project-URL: Documentation, https://github.com/kiarina/pydantic-settings-manager
26
- Project-URL: Repository, https://github.com/kiarina/pydantic-settings-manager
27
- Description-Content-Type: text/markdown
28
-
29
- # pydantic-settings-manager
30
-
31
- A library for managing Pydantic settings objects.
32
-
33
- ## Features
34
-
35
- - Two types of settings managers:
36
- - `SingleSettingsManager`: For managing a single settings object
37
- - `MappedSettingsManager`: For managing multiple settings objects mapped to keys
38
- - Support for loading settings from multiple sources
39
- - Command line argument overrides
40
- - Settings validation through Pydantic
41
- - Type hints and documentation
42
-
43
- ## Installation
44
-
45
- ```bash
46
- pip install pydantic-settings-manager
47
- ```
48
-
49
- ## Quick Start
50
-
51
- ### Single Settings Manager
52
-
53
- ```python
54
- from pydantic_settings import BaseSettings
55
- from pydantic_settings_manager import SingleSettingsManager
56
-
57
- class MySettings(BaseSettings):
58
- name: str = "default"
59
- value: int = 0
60
-
61
- # Create a settings manager
62
- manager = SingleSettingsManager(MySettings)
63
-
64
- # Update settings from a configuration file
65
- manager.user_config = {"name": "from_file", "value": 42}
66
-
67
- # Update settings from command line arguments
68
- manager.cli_args = {"value": 100}
69
-
70
- # Get the current settings (combines both sources)
71
- settings = manager.settings
72
- assert settings.name == "from_file" # from user_config
73
- assert settings.value == 100 # from cli_args (overrides user_config)
74
- ```
75
-
76
- ### Mapped Settings Manager
77
-
78
- ```python
79
- from pydantic_settings import BaseSettings
80
- from pydantic_settings_manager import MappedSettingsManager
81
-
82
- class MySettings(BaseSettings):
83
- name: str = "default"
84
- value: int = 0
85
-
86
- # Create a settings manager
87
- manager = MappedSettingsManager(MySettings)
88
-
89
- # Set up multiple configurations
90
- manager.user_config = {
91
- "map": {
92
- "dev": {"name": "development", "value": 42},
93
- "prod": {"name": "production", "value": 100}
94
- }
95
- }
96
-
97
- # Select which configuration to use
98
- manager.set_cli_args("dev")
99
-
100
- # Get the current settings
101
- settings = manager.settings
102
- assert settings.name == "development"
103
- assert settings.value == 42
104
-
105
- # Switch to a different configuration
106
- manager.set_cli_args("prod")
107
- settings = manager.settings
108
- assert settings.name == "production"
109
- assert settings.value == 100
110
- ```
111
-
112
- ## Documentation
113
-
114
- For more detailed documentation, please see the [GitHub repository](https://github.com/kiarina/pydantic-settings-manager).
115
-
116
- ## License
117
-
118
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
119
-
@@ -1,11 +0,0 @@
1
- pydantic_settings_manager/__init__.py,sha256=6EYixuoo-sI93B6zv4z-WcgQ8CpSboSGKOQgozbBcTo,955
2
- pydantic_settings_manager/base.py,sha256=dZqHHCamZkFirlDCBxJy4AKRqWtE17OmqdiHueQc5gQ,1270
3
- pydantic_settings_manager/mapped.py,sha256=mJJxqCUrFe6vPdZDnsfDNwwyC2dn3b4i2yR6G57JNZg,7715
4
- pydantic_settings_manager/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- pydantic_settings_manager/single.py,sha256=MXCv8-jMdVwEQIjuauEShcZ2849OnjKb3KOyKyE3icw,2771
6
- pydantic_settings_manager/types.py,sha256=XvZoUmmNDjzAr5ns77uq1YhZPocT2BFkLMPZVZt1Lt8,133
7
- pydantic_settings_manager/utils.py,sha256=ciBAczruqEiaudUvk38pCzrjAUz8liIl9JO6QS8hUg0,1322
8
- pydantic_settings_manager-0.1.2.dist-info/LICENSE,sha256=GtwfENGLMnpE6iSmuiVTC1AhFCLGvBYycR--RKNSs80,1060
9
- pydantic_settings_manager-0.1.2.dist-info/METADATA,sha256=69fhvEEn6vIZfjjUiHlXSjpYzqNEFEbUFcK37m6eRkQ,3514
10
- pydantic_settings_manager-0.1.2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
11
- pydantic_settings_manager-0.1.2.dist-info/RECORD,,