ProvenPin Install

Pydantic Settings typed config from env and .env: working versions (tested 2026-10-15)

Typed app configuration with pydantic-settings: env prefixes, nested settings, secrets and validation errors.

passed3 passed · 0 failed2026-10-15 13:10 UTC
Status
passed
Last passed
2026-10-15 13:10 UTC
Tests
3 / 3
Language
Python
Runtime
Python 3.13.16
pinned versions3
pydantic@2.14.1pydantic-settings@2.16.0pytest@9.1.1
run it
uv venv -q .venv && uv pip install -q --python .venv/bin/python -r requirements.txt
.venv/bin/python -m pytest -q
test environment
Python 3.13.16
linux 6.17.0-1022-azure
x64
runner: github-actions 38738874208

The code

Exactly the files that passed. Your agent can pull them with get_recipe("pydantic-settings-config") (install), or see them on GitHub.

requirements.txt
pydantic==2.14.1
pydantic-settings==2.16.0
pytest==9.1.1
settings.py
from pydantic import BaseModel, Field, SecretStr
from pydantic_settings import BaseSettings, SettingsConfigDict

class DbSettings(BaseModel):
    url: str = "sqlite:///app.db"
    pool_size: int = Field(5, ge=1, le=50)

class Settings(BaseSettings):
    model_config = SettingsConfigDict(env_prefix="APP_", env_nested_delimiter="__", env_file=".env", extra="ignore")
    debug: bool = False
    api_key: SecretStr
    db: DbSettings = DbSettings()
tests/test_settings.py
import pytest
from pydantic import ValidationError
from settings import Settings

def test_env_and_nested(monkeypatch):
    monkeypatch.setenv("APP_API_KEY", "s3cret")
    monkeypatch.setenv("APP_DEBUG", "true")
    monkeypatch.setenv("APP_DB__POOL_SIZE", "10")
    s = Settings(_env_file=None)
    assert s.debug is True and s.db.pool_size == 10
    assert s.api_key.get_secret_value() == "s3cret" and "s3cret" not in repr(s)

def test_dotenv(tmp_path, monkeypatch):
    monkeypatch.delenv("APP_API_KEY", raising=False)
    env = tmp_path / ".env"
    env.write_text("APP_API_KEY=fromfile\n")
    assert Settings(_env_file=env).api_key.get_secret_value() == "fromfile"

def test_validation(monkeypatch):
    monkeypatch.setenv("APP_API_KEY", "x")
    monkeypatch.setenv("APP_DB__POOL_SIZE", "500")
    with pytest.raises(ValidationError):
        Settings(_env_file=None)
pytest.ini
[pytest]
pythonpath = .

Connect to ProvenPin

Add the free MCP server so your agent can pull this recipe and others like it. Same setup as the docs.

terminal
claude mcp add --transport http provenpin https://mcp.provenpin.com/mcp

Any other MCP client: Streamable HTTP at https://mcp.provenpin.com/mcp. No API key, no signup.