pydantic-settings-manager 0.2.0__tar.gz → 0.2.2__tar.gz

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.
Files changed (23) hide show
  1. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/CHANGELOG.md +14 -1
  2. pydantic_settings_manager-0.2.2/PKG-INFO +372 -0
  3. pydantic_settings_manager-0.2.2/README.md +346 -0
  4. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/pydantic_settings_manager/__init__.py +1 -1
  5. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/pyproject.toml +1 -1
  6. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/uv.lock +1 -1
  7. pydantic_settings_manager-0.2.0/PKG-INFO +0 -165
  8. pydantic_settings_manager-0.2.0/README.md +0 -139
  9. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/.github/workflows/ci.yml +0 -0
  10. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/.gitignore +0 -0
  11. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/LICENSE +0 -0
  12. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/Makefile +0 -0
  13. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/mypy.ini +0 -0
  14. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/pydantic_settings_manager/base.py +0 -0
  15. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/pydantic_settings_manager/mapped.py +0 -0
  16. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/pydantic_settings_manager/py.typed +0 -0
  17. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/pydantic_settings_manager/single.py +0 -0
  18. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/pydantic_settings_manager/types.py +0 -0
  19. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/pydantic_settings_manager/utils.py +0 -0
  20. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/tests/__init__.py +0 -0
  21. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/tests/test_mapped.py +0 -0
  22. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/tests/test_single.py +0 -0
  23. {pydantic_settings_manager-0.2.0 → pydantic_settings_manager-0.2.2}/tests/test_utils.py +0 -0
@@ -3,7 +3,20 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.2.2] - 2025-06-28
8
+
9
+ ### Changed
10
+ - Version bump: 0.2.1 → 0.2.2
11
+ - Internal version sync in __init__.py
12
+ - docs: add section on pydantic-config-builder in README
13
+
14
+
15
+ ## [0.2.1] - 2025-06-28
16
+
17
+ ### Changed
18
+ - Version bump: 0.2.0 → 0.2.1
19
+ - Internal version sync in __init__.py
7
20
 
8
21
  ## [0.2.0] - 2025-06-28
9
22
 
@@ -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,346 @@
1
+ # pydantic-settings-manager
2
+
3
+ A library for managing Pydantic settings objects.
4
+
5
+ ## Features
6
+
7
+ - Two types of settings managers:
8
+ - `SingleSettingsManager`: For managing a single settings object
9
+ - `MappedSettingsManager`: For managing multiple settings objects mapped to keys
10
+ - Support for loading settings from multiple sources
11
+ - Command line argument overrides
12
+ - Settings validation through Pydantic
13
+ - Type hints and documentation
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pip install pydantic-settings-manager
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ### Basic Usage
24
+
25
+ Let's start with a simple example you can try immediately:
26
+
27
+ ```python
28
+ from pydantic_settings import BaseSettings
29
+ from pydantic_settings_manager import SingleSettingsManager
30
+
31
+ # 1. Define your settings
32
+ class AppSettings(BaseSettings):
33
+ app_name: str = "MyApp"
34
+ debug: bool = False
35
+ max_connections: int = 100
36
+
37
+ # 2. Create a settings manager
38
+ settings_manager = SingleSettingsManager(AppSettings)
39
+
40
+ # 3. Use your settings
41
+ settings = settings_manager.settings
42
+ print(f"App: {settings.app_name}, Debug: {settings.debug}")
43
+ ```
44
+
45
+ ### Loading from Configuration Files
46
+
47
+ You can load settings from external sources:
48
+
49
+ ```python
50
+ # Load from a dictionary (could be from JSON, YAML, etc.)
51
+ settings_manager.user_config = {
52
+ "app_name": "ProductionApp",
53
+ "debug": False,
54
+ "max_connections": 500
55
+ }
56
+
57
+ settings = settings_manager.settings
58
+ print(f"App: {settings.app_name}") # Output: App: ProductionApp
59
+ ```
60
+
61
+ ### Command Line Overrides
62
+
63
+ Override specific settings at runtime:
64
+
65
+ ```python
66
+ # Simulate command line arguments
67
+ settings_manager.cli_args["debug"] = True
68
+ settings_manager.cli_args["max_connections"] = 50
69
+
70
+ # Clear cache to apply changes
71
+ settings_manager.clear()
72
+
73
+ settings = settings_manager.settings
74
+ print(f"Debug: {settings.debug}") # Output: Debug: True
75
+ print(f"Connections: {settings.max_connections}") # Output: Connections: 50
76
+ ```
77
+
78
+ ### Multiple Configurations (Mapped Settings)
79
+
80
+ For managing multiple environments or configurations:
81
+
82
+ ```python
83
+ from pydantic_settings_manager import MappedSettingsManager
84
+
85
+ # Create a mapped settings manager
86
+ mapped_manager = MappedSettingsManager(AppSettings)
87
+
88
+ # Configure multiple environments
89
+ mapped_manager.user_config = {
90
+ "map": {
91
+ "development": {
92
+ "app_name": "MyApp-Dev",
93
+ "debug": True,
94
+ "max_connections": 10
95
+ },
96
+ "production": {
97
+ "app_name": "MyApp-Prod",
98
+ "debug": False,
99
+ "max_connections": 1000
100
+ }
101
+ }
102
+ }
103
+
104
+ # Switch between configurations
105
+ mapped_manager.set_cli_args("development")
106
+ dev_settings = mapped_manager.settings
107
+ print(f"Dev: {dev_settings.app_name}, Debug: {dev_settings.debug}")
108
+
109
+ mapped_manager.set_cli_args("production")
110
+ prod_settings = mapped_manager.settings
111
+ print(f"Prod: {prod_settings.app_name}, Debug: {prod_settings.debug}")
112
+ ```
113
+
114
+ ## Advanced Usage
115
+
116
+ ### Project Structure for Large Applications
117
+
118
+ For complex applications with multiple modules, you can organize your settings like this:
119
+
120
+ ```
121
+ your_project/
122
+ ├── hoge/
123
+ │ ├── __init__.py
124
+ │ ├── settings.py
125
+ │ ├── client.py
126
+ │ └── registry.py
127
+ ├── fuga/
128
+ │ ├── __init__.py
129
+ │ ├── settings.py
130
+ │ ├── client.py
131
+ │ └── registry.py
132
+ ├── bootstrap.py
133
+ ├── __main__.py
134
+ └── config.yaml
135
+ ```
136
+
137
+ ### Module-based Settings Management
138
+
139
+ ```python
140
+ # fuga/__init__.py
141
+ from .settings import settings_manager
142
+
143
+ __all__ = ["settings_manager"]
144
+ ```
145
+
146
+ ```python
147
+ # fuga/settings.py
148
+ from pydantic_settings import BaseSettings
149
+ from pydantic_settings_manager import MappedSettingsManager
150
+
151
+ class FugaSettings(BaseSettings):
152
+ name: str = "default"
153
+ api_key: str = "***"
154
+
155
+ settings_manager = MappedSettingsManager(FugaSettings)
156
+ ```
157
+
158
+ ```python
159
+ # fuga/client.py
160
+ from .settings import FugaSettings
161
+
162
+ class FugaClient:
163
+ def __init__(self, settings: FugaSettings):
164
+ self.settings = settings
165
+ ```
166
+
167
+ ```python
168
+ # fuga/registry.py
169
+ from .settings import settings_manager
170
+
171
+ def create_fuga_client(config_key: str = ""):
172
+ settings = settings_manager.get_settings_by_key(config_key)
173
+ return FugaClient(settings)
174
+ ```
175
+
176
+ ### Bootstrap
177
+
178
+ 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.
179
+
180
+ ```yaml
181
+ # config.yaml
182
+ hoge:
183
+ name: "star"
184
+ value: 7
185
+ fuga:
186
+ key: first
187
+ map:
188
+ first:
189
+ name: "first"
190
+ api_key: "***"
191
+ second:
192
+ name: "second"
193
+ api_key: "***"
194
+ ```
195
+
196
+ ```python
197
+ # bootstrap.py
198
+ import importlib
199
+ import yaml
200
+
201
+ from pydantic_settings_manager import BaseSettingsManager
202
+
203
+ def bootstrap():
204
+ config = yaml.safe_load(open("/path/to/config.yaml"))
205
+
206
+ for module_name, user_config in config.items():
207
+ try:
208
+ module = importlib.import_module(module_name)
209
+ settings_manager = getattr(module, 'settings_manager', None)
210
+
211
+ if isinstance(settings_manager, BaseSettingsManager):
212
+ settings_manager.user_config = user_config
213
+ settings_manager.clear()
214
+ ```
215
+
216
+ ### CLI Integration
217
+
218
+ 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.
219
+
220
+ ```python
221
+ # __main__.py
222
+ import click
223
+
224
+ from .bootstrap import bootstrap
225
+ from .hoge import settings_manager as hoge_settings_manager
226
+ from .fuga import settings_manager as fuga_settings_manager
227
+
228
+ @click.command
229
+ @click.option("--name", type=str, default="", help="Name of the Hoge")
230
+ @click.option("--key", type=str, default="", help="Key for Fuga settings")
231
+ def main(name: str, key: str):
232
+ bootstrap()
233
+
234
+ if name:
235
+ hoge_settings_manager.cli_args["name"] = name
236
+ hoge_settings_manager.clear()
237
+
238
+ if key:
239
+ fuga_settings_manager.cli_args["key"] = key
240
+ fuga_settings_manager.clear()
241
+
242
+ # ...
243
+ ```
244
+
245
+ ## Related Tools
246
+
247
+ ### pydantic-config-builder
248
+
249
+ 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:
250
+
251
+ ```bash
252
+ pip install pydantic-config-builder
253
+ ```
254
+
255
+ This tool allows you to:
256
+ - Merge multiple YAML files into a single configuration
257
+ - Use base configurations with overlay files
258
+ - Build different configurations for different environments
259
+ - Support glob patterns and recursive merging
260
+
261
+ Example workflow:
262
+ ```yaml
263
+ # pydantic_config_builder.yml
264
+ development:
265
+ input:
266
+ - base/*.yaml
267
+ - dev-overrides.yaml
268
+ output:
269
+ - config/dev.yaml
270
+
271
+ production:
272
+ input:
273
+ - base/*.yaml
274
+ - prod-overrides.yaml
275
+ output:
276
+ - config/prod.yaml
277
+ ```
278
+
279
+ Then use the generated configurations with your settings manager:
280
+ ```python
281
+ import yaml
282
+ from your_app import settings_manager
283
+
284
+ # Load the built configuration
285
+ with open("config/dev.yaml") as f:
286
+ config = yaml.safe_load(f)
287
+
288
+ settings_manager.user_config = config
289
+ ```
290
+
291
+ ## Development
292
+
293
+ This project uses modern Python development tools with flexible dependency groups:
294
+
295
+ - **ruff**: Fast linter and formatter (replaces black, isort, and flake8)
296
+ - **mypy**: Static type checking
297
+ - **pytest**: Testing framework with coverage reporting
298
+ - **uv**: Fast Python package manager with PEP 735 dependency groups support
299
+
300
+ ### Setup
301
+
302
+ ```bash
303
+ # Install all development dependencies
304
+ uv sync --group dev
305
+
306
+ # Or install specific dependency groups
307
+ uv sync --group test # Testing tools only
308
+ uv sync --group lint # Linting tools only
309
+
310
+ # Format code
311
+ uv run ruff check --fix .
312
+
313
+ # Run linting
314
+ uv run ruff check .
315
+ uv run mypy .
316
+
317
+ # Run tests
318
+ uv run pytest --cov=pydantic_settings_manager tests/
319
+
320
+ # Build and test everything
321
+ make build
322
+ ```
323
+
324
+ ### Development Workflow
325
+
326
+ ```bash
327
+ # Quick setup for testing
328
+ uv sync --group test
329
+ make test
330
+
331
+ # Quick setup for linting
332
+ uv sync --group lint
333
+ make lint
334
+
335
+ # Full development environment
336
+ uv sync --group dev
337
+ make build
338
+ ```
339
+
340
+ ## Documentation
341
+
342
+ For more detailed documentation, please see the [GitHub repository](https://github.com/kiarina/pydantic-settings-manager).
343
+
344
+ ## License
345
+
346
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -21,7 +21,7 @@ from .base import BaseSettingsManager
21
21
  from .mapped import MappedSettingsManager, SettingsMap
22
22
  from .single import SingleSettingsManager
23
23
 
24
- __version__ = "0.2.0"
24
+ __version__ = "0.2.2"
25
25
 
26
26
  __all__ = [
27
27
  # Re-exports from pydantic_settings
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pydantic-settings-manager"
3
- version = "0.2.0"
3
+ version = "0.2.2"
4
4
  description = "A library for managing Pydantic settings objects"
5
5
  authors = [
6
6
  { name = "kiarina", email = "kiarinadawa@gmail.com" }
@@ -341,7 +341,7 @@ wheels = [
341
341
 
342
342
  [[package]]
343
343
  name = "pydantic-settings-manager"
344
- version = "0.2.0"
344
+ version = "0.2.2"
345
345
  source = { editable = "." }
346
346
  dependencies = [
347
347
  { name = "pydantic" },
@@ -1,165 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pydantic-settings-manager
3
- Version: 0.2.0
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
- ### Single Settings Manager
50
-
51
- ```python
52
- from pydantic_settings import BaseSettings
53
- from pydantic_settings_manager import SingleSettingsManager
54
-
55
- class MySettings(BaseSettings):
56
- name: str = "default"
57
- value: int = 0
58
-
59
- # Create a settings manager
60
- manager = SingleSettingsManager(MySettings)
61
-
62
- # Update settings from a configuration file
63
- manager.user_config = {"name": "from_file", "value": 42}
64
-
65
- # Update settings from command line arguments
66
- manager.cli_args = {"value": 100}
67
-
68
- # Get the current settings (combines both sources)
69
- settings = manager.settings
70
- assert settings.name == "from_file" # from user_config
71
- assert settings.value == 100 # from cli_args (overrides user_config)
72
- ```
73
-
74
- ### Mapped Settings Manager
75
-
76
- ```python
77
- from pydantic_settings import BaseSettings
78
- from pydantic_settings_manager import MappedSettingsManager
79
-
80
- class MySettings(BaseSettings):
81
- name: str = "default"
82
- value: int = 0
83
-
84
- # Create a settings manager
85
- manager = MappedSettingsManager(MySettings)
86
-
87
- # Set up multiple configurations
88
- manager.user_config = {
89
- "map": {
90
- "dev": {"name": "development", "value": 42},
91
- "prod": {"name": "production", "value": 100}
92
- }
93
- }
94
-
95
- # Select which configuration to use
96
- manager.set_cli_args("dev")
97
-
98
- # Get the current settings
99
- settings = manager.settings
100
- assert settings.name == "development"
101
- assert settings.value == 42
102
-
103
- # Switch to a different configuration
104
- manager.set_cli_args("prod")
105
- settings = manager.settings
106
- assert settings.name == "production"
107
- assert settings.value == 100
108
- ```
109
-
110
- ## Development
111
-
112
- This project uses modern Python development tools with flexible dependency groups:
113
-
114
- - **ruff**: Fast linter and formatter (replaces black, isort, and flake8)
115
- - **mypy**: Static type checking
116
- - **pytest**: Testing framework with coverage reporting
117
- - **uv**: Fast Python package manager with PEP 735 dependency groups support
118
-
119
- ### Setup
120
-
121
- ```bash
122
- # Install all development dependencies
123
- uv sync --group dev
124
-
125
- # Or install specific dependency groups
126
- uv sync --group test # Testing tools only
127
- uv sync --group lint # Linting tools only
128
-
129
- # Format code
130
- uv run ruff check --fix .
131
-
132
- # Run linting
133
- uv run ruff check .
134
- uv run mypy .
135
-
136
- # Run tests
137
- uv run pytest --cov=pydantic_settings_manager tests/
138
-
139
- # Build and test everything
140
- make build
141
- ```
142
-
143
- ### Development Workflow
144
-
145
- ```bash
146
- # Quick setup for testing
147
- uv sync --group test
148
- make test
149
-
150
- # Quick setup for linting
151
- uv sync --group lint
152
- make lint
153
-
154
- # Full development environment
155
- uv sync --group dev
156
- make build
157
- ```
158
-
159
- ## Documentation
160
-
161
- For more detailed documentation, please see the [GitHub repository](https://github.com/kiarina/pydantic-settings-manager).
162
-
163
- ## License
164
-
165
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -1,139 +0,0 @@
1
- # pydantic-settings-manager
2
-
3
- A library for managing Pydantic settings objects.
4
-
5
- ## Features
6
-
7
- - Two types of settings managers:
8
- - `SingleSettingsManager`: For managing a single settings object
9
- - `MappedSettingsManager`: For managing multiple settings objects mapped to keys
10
- - Support for loading settings from multiple sources
11
- - Command line argument overrides
12
- - Settings validation through Pydantic
13
- - Type hints and documentation
14
-
15
- ## Installation
16
-
17
- ```bash
18
- pip install pydantic-settings-manager
19
- ```
20
-
21
- ## Quick Start
22
-
23
- ### Single Settings Manager
24
-
25
- ```python
26
- from pydantic_settings import BaseSettings
27
- from pydantic_settings_manager import SingleSettingsManager
28
-
29
- class MySettings(BaseSettings):
30
- name: str = "default"
31
- value: int = 0
32
-
33
- # Create a settings manager
34
- manager = SingleSettingsManager(MySettings)
35
-
36
- # Update settings from a configuration file
37
- manager.user_config = {"name": "from_file", "value": 42}
38
-
39
- # Update settings from command line arguments
40
- manager.cli_args = {"value": 100}
41
-
42
- # Get the current settings (combines both sources)
43
- settings = manager.settings
44
- assert settings.name == "from_file" # from user_config
45
- assert settings.value == 100 # from cli_args (overrides user_config)
46
- ```
47
-
48
- ### Mapped Settings Manager
49
-
50
- ```python
51
- from pydantic_settings import BaseSettings
52
- from pydantic_settings_manager import MappedSettingsManager
53
-
54
- class MySettings(BaseSettings):
55
- name: str = "default"
56
- value: int = 0
57
-
58
- # Create a settings manager
59
- manager = MappedSettingsManager(MySettings)
60
-
61
- # Set up multiple configurations
62
- manager.user_config = {
63
- "map": {
64
- "dev": {"name": "development", "value": 42},
65
- "prod": {"name": "production", "value": 100}
66
- }
67
- }
68
-
69
- # Select which configuration to use
70
- manager.set_cli_args("dev")
71
-
72
- # Get the current settings
73
- settings = manager.settings
74
- assert settings.name == "development"
75
- assert settings.value == 42
76
-
77
- # Switch to a different configuration
78
- manager.set_cli_args("prod")
79
- settings = manager.settings
80
- assert settings.name == "production"
81
- assert settings.value == 100
82
- ```
83
-
84
- ## Development
85
-
86
- This project uses modern Python development tools with flexible dependency groups:
87
-
88
- - **ruff**: Fast linter and formatter (replaces black, isort, and flake8)
89
- - **mypy**: Static type checking
90
- - **pytest**: Testing framework with coverage reporting
91
- - **uv**: Fast Python package manager with PEP 735 dependency groups support
92
-
93
- ### Setup
94
-
95
- ```bash
96
- # Install all development dependencies
97
- uv sync --group dev
98
-
99
- # Or install specific dependency groups
100
- uv sync --group test # Testing tools only
101
- uv sync --group lint # Linting tools only
102
-
103
- # Format code
104
- uv run ruff check --fix .
105
-
106
- # Run linting
107
- uv run ruff check .
108
- uv run mypy .
109
-
110
- # Run tests
111
- uv run pytest --cov=pydantic_settings_manager tests/
112
-
113
- # Build and test everything
114
- make build
115
- ```
116
-
117
- ### Development Workflow
118
-
119
- ```bash
120
- # Quick setup for testing
121
- uv sync --group test
122
- make test
123
-
124
- # Quick setup for linting
125
- uv sync --group lint
126
- make lint
127
-
128
- # Full development environment
129
- uv sync --group dev
130
- make build
131
- ```
132
-
133
- ## Documentation
134
-
135
- For more detailed documentation, please see the [GitHub repository](https://github.com/kiarina/pydantic-settings-manager).
136
-
137
- ## License
138
-
139
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.