A flexible Python library for parsing configuration strings with support for key:value pairs, quoted values, ranges, negation, numeric coercion, and strict validation.
- Key:Value Parsing -
timeout:30 retries:3 - Quoted Values -
name:"John Doe"with escape support - Ranges -
port:8080..9090parsed as tuples - Negation -
-verboseto exclude keys - Numeric Coercion - automatic int/float detection
- Defaults - merge defaults with override semantics (
Noneremoves a key) - Strict Mode - validate against an allowlist of keys
- Statistics - track parse calls and keys found
pip install -e .from smart_config_parser import parse_config, ConfigDefaults
# Basic parsing
result = parse_config("timeout:30 retries:3 -verbose")
# {'params': {'timeout': 30, 'retries': 3}, 'excluded': {'verbose': True}, 'text': []}
# With defaults
result = parse_config("retries:5", defaults={"timeout": 30})
# {'params': {'timeout': 30, 'retries': 5}, ...}
# Ranges
result = parse_config("port:8080..9090")
# {'params': {'port': (8080, 9090)}, ...}
# Strict mode
result = parse_config("timeout:30", strict=True, allowed_keys={"timeout", "retries"})pytest