A library for managing Pydantic settings objects
Project description
pydantic-settings-manager
A library for managing Pydantic settings objects.
Features
- Two types of settings managers:
SingleSettingsManager: For managing a single settings objectMappedSettingsManager: For managing multiple settings objects mapped to keys
- Support for loading settings from multiple sources
- Command line argument overrides
- Settings validation through Pydantic
- Type hints and documentation
Installation
pip install pydantic-settings-manager
Quick Start
Single Settings Manager
from pydantic_settings import BaseSettings
from pydantic_settings_manager import SingleSettingsManager
class MySettings(BaseSettings):
name: str = "default"
value: int = 0
# Create a settings manager
manager = SingleSettingsManager(MySettings)
# Update settings from a configuration file
manager.user_config = {"name": "from_file", "value": 42}
# Update settings from command line arguments
manager.cli_args = {"value": 100}
# Get the current settings (combines both sources)
settings = manager.settings
assert settings.name == "from_file" # from user_config
assert settings.value == 100 # from cli_args (overrides user_config)
Mapped Settings Manager
from pydantic_settings import BaseSettings
from pydantic_settings_manager import MappedSettingsManager
class MySettings(BaseSettings):
name: str = "default"
value: int = 0
# Create a settings manager
manager = MappedSettingsManager(MySettings)
# Set up multiple configurations
manager.user_config = {
"map": {
"dev": {"name": "development", "value": 42},
"prod": {"name": "production", "value": 100}
}
}
# Select which configuration to use
manager.set_cli_args("dev")
# Get the current settings
settings = manager.settings
assert settings.name == "development"
assert settings.value == 42
# Switch to a different configuration
manager.set_cli_args("prod")
settings = manager.settings
assert settings.name == "production"
assert settings.value == 100
Development
This project uses modern Python development tools with flexible dependency groups:
- ruff: Fast linter and formatter (replaces black, isort, and flake8)
- mypy: Static type checking
- pytest: Testing framework with coverage reporting
- uv: Fast Python package manager with PEP 735 dependency groups support
Setup
# Install all development dependencies
uv sync --group dev
# Or install specific dependency groups
uv sync --group test # Testing tools only
uv sync --group lint # Linting tools only
# Format code
uv run ruff check --fix .
# Run linting
uv run ruff check .
uv run mypy .
# Run tests
uv run pytest --cov=pydantic_settings_manager tests/
# Build and test everything
make build
Development Workflow
# Quick setup for testing
uv sync --group test
make test
# Quick setup for linting
uv sync --group lint
make lint
# Full development environment
uv sync --group dev
make build
Documentation
For more detailed documentation, please see the GitHub repository.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydantic_settings_manager-0.2.0.tar.gz.
File metadata
- Download URL: pydantic_settings_manager-0.2.0.tar.gz
- Upload date:
- Size: 39.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea1f7a58663395dfe70f15ac202bc84cbd2c2a1a1c262f5f34cd1bc5c8b5b6aa
|
|
| MD5 |
f321b231564425c5105e704e323ec795
|
|
| BLAKE2b-256 |
b5cc2811df1cc7c4fe6b487b7fbb87dfafe34c4d26c395bcfb9f73eaf1327822
|
File details
Details for the file pydantic_settings_manager-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pydantic_settings_manager-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ad61456839a1890e2a3fb4cc6a9dddd7cc78a84aa342536ea23532485407d7a
|
|
| MD5 |
040d24bb7132f90c27910ebd2d859b33
|
|
| BLAKE2b-256 |
512d3a61976e6de54a716c102d6bcb87bbf4a43af73f55fa0017be9550d506b7
|