Skip to content

Latest commit

 

History

History

docs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Pydantic settings

Hipster-orgazmic tool to mange application settings

Build Status

PyPI version

Documentation Status

Library which extends pydantic functionality in scope of application settings. Pydantic already have settings implementation, e.g. pydantic.BaseSettings, but from my point it's missing some useful features:

  1. Overriding settings values by environment variables even for nested fields
  2. Providing detailed information about value location inside a loaded file or environment variable, which helps to point user mistake
  3. Documenting model fields isn't feels comfortable, but it's really essential to write comprehensive documentation for application settings

NOTE: Beta quality

Installation

Using pip:

pip install pydantic-settings

Usage example

Override values by env variables

Allows to override values for nested fields if they are represented as pydantic model.

Here is example:

.. literalinclude:: examples/override_by_env.py :language: python

Point exact error location inside file

.. literalinclude:: examples/loc_inside_text_content.py :language: python

Extracts fields documentation

Allows to extract Sphinx style attributes documentation by processing AST tree of class definition

.. literalinclude:: examples/attr_docs_example.py :language: python

Online docs

Read more detailed documentation on the project Read The Docs page.

Development setup

Project requires poetry for development setup.

  • If you aren't have it already
pip install poetry
  • Install project dependencies
poetry install
  • Run tests
poetry run pytest .
  • Great, all works! Expect one optional step:

  • Install pre-commit for pre-commit hooks

pip install pre-commit
pre-commit install

That will install pre-commit hooks, which will check code with flake8 and black.

NOTE project uses black as code formatter, but i'am personally really dislike their "double quoted strings everywhere" style, that's why black -S should be used (anyway it's configured in pyproject.toml file)