Hipster-orgazmic tool to mange application settings
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:
- Overriding settings values by environment variables even for nested fields
- Providing detailed information about value location inside a loaded file or environment variable, which helps to point user mistake
- Documenting model fields isn't feels comfortable, but it's really essential to write comprehensive documentation for application settings
NOTE: Beta quality
Using pip:
pip install pydantic-settings
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
.. literalinclude:: examples/loc_inside_text_content.py :language: python
Allows to extract Sphinx style attributes documentation by processing AST tree of class definition
.. literalinclude:: examples/attr_docs_example.py :language: python
Read more detailed documentation on the project Read The Docs page.
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)