Skip to main content

Pydantic-powered config management

Project description

Pattern Agentic Settings

A settings class based on pydantic-settings that facilitates:

  • printing all settings on startup (redacts senstive attrs)
  • easy loading of .env files via an env variable
  • optionally load app version from importlib (sourced from pyproject.toml)
  • optional hot reload using watchfiles

Example

class Settings(PABaseSettings):
    model_config = SettingsConfigDict(
        env_prefix="MYAPP_"
    )
    worker_count: int

# expects MYAPP_WORKER_COUNT 
# if MYAPP_DOT_ENV points to a file, will try to load vars from it
# throws an error if not defined
settings = Settings.load('my_app')

Exepcted output:

My App v1.0.0
Configuration:
  WORKER_COUNT: 3

And on failure:

RuntimeError: Configuration validation failed:

      Missing required configuration fields:
        - worker_count

Tests

To run the tests the package must be installed in edit mode:

uv pip install -e .

# or to test hotreload
uv pip install -e .[hotreload]

After that:

# Base test
uv run pytest tests/test_base.py

# All tests
uv run pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pattern_agentic_settings-1.0.1.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pattern_agentic_settings-1.0.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file pattern_agentic_settings-1.0.1.tar.gz.

File metadata

  • Download URL: pattern_agentic_settings-1.0.1.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for pattern_agentic_settings-1.0.1.tar.gz
Algorithm Hash digest
SHA256 18d963599eb7cbe6e777d92cb34899c1dec19fb85c3444893b01de055b84a9af
MD5 de5bb700f99160fb3b348ef6dad26ae0
BLAKE2b-256 f3e4dc37503beec15266d0056ca05e241e123b70bee5953a1d644d44d7149c9d

See more details on using hashes here.

File details

Details for the file pattern_agentic_settings-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pattern_agentic_settings-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8f7ca70b12fb530dc58e275826fc23fb84d4a13e126175525ed84d27e758d1b3
MD5 74d2d2998fcc9a09f6cc828e213d19ab
BLAKE2b-256 5050f0c5f817466f185f150d0b103be2fa87ff8a4823c21f6bd69022331493af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page