Skip to content

Maison

Actions Status Actions Status codecov

When developing a python application, e.g a command-line tool, it can be helpful to allow the user to set their own configuration options to allow them to tailor the tool to their needs. These options are typically set in files in the root of a project directory that uses the tool, for example in a pyproject.toml file.

maison aims to provide a simple and flexible way to read and validate those configuration options so that they may be used in the application.

Installing

pip install maison

Example

Suppose we have a pyproject.toml which looks like the following:

[tool.acme]
foo = "bar"

In order to read the value of foo, run the following:

from maison import ProjectConfig

config = ProjectConfig(project_name="acme")
foo_option = config.get_option("foo")

print(foo_option)
#> "bar"