A library to create ergonomic, auto-validated configuration models with great support for static type annotations.
Project description
Comprehensive Configuration
A simple configuration library that lets you create a pydantic-like model for your configuration.
Installation
pip install comprehensiveconfig
Features
- Supports static type checking
- toml writer
- json writer
- Number Fields
- Text Fields (with regex filtering)
- List fields
- Table fields
- TableSpec (Model) fields
- Sections
- Include doc comments in Section
- auto loading
- initialize default config (with auto loader)
- yaml writer
- Tests targetting mypy and other static type checkers to ensure EVERYTHING looks good across IDE's
- section list (via a Table field)
- Field type unions (overwriting normal union syntax)
- per attribute doc comments (inline and noninline)
- enum support (Via
spec.ConfigEnumand python'senum.Enum) - fully supported string escapes
Example (Python)
# example.py
from comprehensiveconfig import ConfigSpec
from comprehensiveconfig.spec import Section, Integer, Float, Text, List
from comprehensiveconfig.toml import TomlWriter
class MyConfigSpec(ConfigSpec,
default_file="myconfig.toml",
writer=TomlWriter,
create_file=True):
class MySection(Section, name="My_Section"):
some_field = Integer(10)
other_field = Text("Some Default Text")
class SubSection(Section):
'''An example Sub Section'''
x = Integer(10)
class Credentials(Section):
'''Example credentials section'''
email = Text("example@email.com", regex=r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$")
password = Text("MyPassword")
some_field = Float(6.9)
list_of_stuff = List(["12", "13", "14"], inner_type=Text())
# Accessing values from globally loaded config (if one exists, otherwise it accesses the actual Field class)
print(MyConfigSpec.some_field)
print(MyConfigSpec.MySection.other_field)
# Another way to open configuration
second_config = MyConfigSpec.load("another_config.toml", TomlWriter)
Example (toml output)
some_field = 6.9
list_of_stuff = ["12", "13", "14"]
[My_Section]
some_field = 10
other_field = "Some Default Text"
[My_Section.SubSection]
# An example Sub Section
x = 10
[Credentials]
# Example credentials section
email = "example@email.com"
password = "MyPassword"
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
comprehensiveconfig-1.1.2.tar.gz
(17.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file comprehensiveconfig-1.1.2.tar.gz.
File metadata
- Download URL: comprehensiveconfig-1.1.2.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cec0fb1cedca5210b4428cfa558c0221d72690bca24e978d0cc5cab19a2813ce
|
|
| MD5 |
e735631dedfa78ea690238df13322a90
|
|
| BLAKE2b-256 |
fa07909802aac24ff3ff83ba77472a4fc3af5cdff85a17d19b8bdcdccd53dbec
|
File details
Details for the file comprehensiveconfig-1.1.2-py3-none-any.whl.
File metadata
- Download URL: comprehensiveconfig-1.1.2-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3c939a783d66f5d276175904c4d0ce7948927369605a3d1dd38ab45ac493085
|
|
| MD5 |
c0ba6635e9d94e26e9aeeb31738c3649
|
|
| BLAKE2b-256 |
4e73374c823c5a6424a4465f2286f06ab452d7b0f37f66b1f0d9b35a53786aa4
|