pydantic-settings-manager 0.1.2__py3-none-any.whl → 0.2.0__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.
- pydantic_settings_manager/__init__.py +4 -4
- pydantic_settings_manager/base.py +3 -3
- pydantic_settings_manager/mapped.py +10 -10
- pydantic_settings_manager/single.py +4 -4
- pydantic_settings_manager/types.py +3 -2
- pydantic_settings_manager/utils.py +3 -3
- {pydantic_settings_manager-0.1.2.dist-info → pydantic_settings_manager-0.2.0.dist-info}/METADATA +60 -14
- pydantic_settings_manager-0.2.0.dist-info/RECORD +11 -0
- {pydantic_settings_manager-0.1.2.dist-info → pydantic_settings_manager-0.2.0.dist-info}/WHEEL +1 -1
- pydantic_settings_manager-0.1.2.dist-info/RECORD +0 -11
- {pydantic_settings_manager-0.1.2.dist-info → pydantic_settings_manager-0.2.0.dist-info/licenses}/LICENSE +0 -0
@@ -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.
|
24
|
+
__version__ = "0.2.0"
|
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,
|
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:
|
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:
|
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,
|
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:
|
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:
|
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:
|
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:
|
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) ->
|
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) ->
|
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=(
|
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 =
|
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) ->
|
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,
|
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:
|
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:
|
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:
|
58
|
+
self.user_config: dict[str, Any] = {}
|
59
59
|
"""User configuration"""
|
60
60
|
|
61
61
|
self._settings: Union[T, None] = None
|
@@ -2,12 +2,12 @@
|
|
2
2
|
Utility functions for dictionary operations.
|
3
3
|
"""
|
4
4
|
from collections import defaultdict
|
5
|
-
from typing import Any
|
5
|
+
from typing import Any
|
6
6
|
|
7
7
|
from .types import NestedDict
|
8
8
|
|
9
9
|
|
10
|
-
def diff_dict(base:
|
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:
|
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.
|
{pydantic_settings_manager-0.1.2.dist-info → pydantic_settings_manager-0.2.0.dist-info}/METADATA
RENAMED
@@ -1,29 +1,27 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: pydantic-settings-manager
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.2.0
|
4
4
|
Summary: A library for managing Pydantic settings objects
|
5
|
-
|
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>
|
6
9
|
License: MIT
|
7
|
-
|
8
|
-
|
9
|
-
Author-email: kiarinadawa@gmail.com
|
10
|
-
Requires-Python: >=3.8,<4.0
|
10
|
+
License-File: LICENSE
|
11
|
+
Keywords: configuration,pydantic,settings
|
11
12
|
Classifier: Development Status :: 4 - Beta
|
12
13
|
Classifier: Intended Audience :: Developers
|
13
14
|
Classifier: License :: OSI Approved :: MIT License
|
14
15
|
Classifier: Operating System :: OS Independent
|
15
16
|
Classifier: Programming Language :: Python :: 3
|
16
|
-
Classifier: Programming Language :: Python :: 3.8
|
17
17
|
Classifier: Programming Language :: Python :: 3.9
|
18
18
|
Classifier: Programming Language :: Python :: 3.10
|
19
19
|
Classifier: Programming Language :: Python :: 3.11
|
20
20
|
Classifier: Programming Language :: Python :: 3.12
|
21
|
-
Classifier: Programming Language :: Python :: 3.13
|
22
21
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
23
|
-
Requires-
|
24
|
-
Requires-Dist: pydantic-settings
|
25
|
-
|
26
|
-
Project-URL: Repository, https://github.com/kiarina/pydantic-settings-manager
|
22
|
+
Requires-Python: >=3.9
|
23
|
+
Requires-Dist: pydantic-settings>=2.0.0
|
24
|
+
Requires-Dist: pydantic>=2.0.0
|
27
25
|
Description-Content-Type: text/markdown
|
28
26
|
|
29
27
|
# pydantic-settings-manager
|
@@ -109,6 +107,55 @@ assert settings.name == "production"
|
|
109
107
|
assert settings.value == 100
|
110
108
|
```
|
111
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
|
+
|
112
159
|
## Documentation
|
113
160
|
|
114
161
|
For more detailed documentation, please see the [GitHub repository](https://github.com/kiarina/pydantic-settings-manager).
|
@@ -116,4 +163,3 @@ For more detailed documentation, please see the [GitHub repository](https://gith
|
|
116
163
|
## License
|
117
164
|
|
118
165
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
119
|
-
|
@@ -0,0 +1,11 @@
|
|
1
|
+
pydantic_settings_manager/__init__.py,sha256=qlee3Dzwc5Noldzte2FpCr3VjsNOpFVKNP9n0YBWsUs,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.0.dist-info/METADATA,sha256=Q-LlWjq7ae7TOjAorJGcf50YR8jytFu_PNjKAEJhV1w,4383
|
9
|
+
pydantic_settings_manager-0.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
10
|
+
pydantic_settings_manager-0.2.0.dist-info/licenses/LICENSE,sha256=GtwfENGLMnpE6iSmuiVTC1AhFCLGvBYycR--RKNSs80,1060
|
11
|
+
pydantic_settings_manager-0.2.0.dist-info/RECORD,,
|
@@ -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,,
|
File without changes
|