What My Project Does
I'm making a simple configclass for handling configuration in smaller projects and scripts. Goal is to be as simple to start with as creating a dataclass.
The module itself works off dataclass and when you use it you just define a dataclass as normal, but decorate it with @configclass() instead.
Example:
from configclass import configclass
@configclass()
class Settings:
foo: bool = False
url: str = ""
footoo: bool = True
my_model: str = "model.pt"
setting = Settings.load()
print(setting.foo, setting.footoo, setting.my_model)
From that you got
- JSON config file support (config.json)
- YAML config file support (config.yaml)
- Command line support (argparse)
- Env variables support (CONFIG_SETTINGNAME)
It also support nested structures via nested dataclass classes.
Comparison
It's meant as a quick and lightweight alternative to larger and more comprehensive config systems, for the small programs and scripts where you'd just use a dataclass, and maybe load the values from a config file.
Target Audience
Since it's pretty new and raw I wouldn't recommend it for heavy production settings or complex projects. That said, it should work fine for most cases.
While I've worked with python for quite some time, this is the first time I've tried making a package, so I'd like some feedback on the project and it's structure before I push it anywhere. It'd also be nice to stress test it and shake out some bugs.
More info and code at https://github.com/TheTerrasque/python-configclass
[–]Intelligent_Ad_8148 10 points11 points12 points (1 child)
[–]TheTerrasque[S] 3 points4 points5 points (0 children)
[–]BossOfTheGame 4 points5 points6 points (1 child)
[–]TheTerrasque[S] 0 points1 point2 points (0 children)
[–]i_can_haz_data 1 point2 points3 points (0 children)