Configuration files using Pydantic and YAML
Often when working on custom Python tooling or commandline applications it might be helpful to have some sort of configuration file rather than passing a long list of flags and arguments in the shell. There are a lot of different configuration file formats people use like ini, toml, json and yaml. Generally I prefer YAML because of its easy to read structure and the simplicity with which it maps to Python objects, particularly dictionaries. YAML also supports comments which can be a big plus when you want to explain what parameters are or why you have a particularly value for your deployment.
This post describes one implementation for managing YAML configurations using Pydantic with some improvements for usability and documentation.