Skip to content

python as config when toml, yaml, json can't handle. Sacrificed runtime safety so **only run trusted code**

License

Notifications You must be signed in to change notification settings

AClon314/turing_config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

turning_config

Use program language like python for config, when json/yaml/toml is not enough. This sacrificed runtime safety, so only run trusted code(Beware eval(), exec() used and import packages)

Usage

see defaultConfig.py

# defaultConfig.py
from typing import *
from dataclasses import dataclass
from runtime_type_checker import check_types
from turing_config import sync_config, bind_config
from pathlib import Path

@check_types
@dataclass
@sync_config(package=__package__) # or @config(path=Path(...)) manually
class Config:
    mode: Literal["dev", "prod", "test"] = "dev"
    port: int = 8000

CONFIG = bind_config(Config)

About

python as config when toml, yaml, json can't handle. Sacrificed runtime safety so **only run trusted code**

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages