Contributing#

Development Setup#

Clone and install in editable mode:

git clone https://github.com/jeankossaifi/zencfg
cd zencfg
pip install -e .

Run tests:

python -m pytest src/zencfg/tests/

Build documentation:

cd docs
sphinx-build -b html . _build/html

Internal Implementation#

These functions are used internally by ZenCFG. They’re documented here for contributors and advanced users who want to understand how the library works.

parse_value_to_type#

Converts values to their expected types using Pydantic validation.

zencfg.config.parse_value_to_type(value: Any, field_type: Type, strict: bool = True, path: str = '') Any[source]#

Parse a value to match its expected type.

Strings are tried as JSON first (so “[4, 5]” can fill a List[int] field), then validated directly. Types involving ConfigBase are passed through: they are validated by the config machinery itself, not here.

Parameters:
  • value (Any) – The value to parse

  • field_type (Type) – The expected type

  • strict (bool) – If True, raises on conversion errors. If False, returns the original value when conversion fails.

  • path (str) – Path in the config hierarchy, used for error messages

Returns:

The parsed value

Return type:

Any

Raises:

TypeError – If value cannot be converted to the expected type and strict=True

is_configbase_type#

Checks if a type is a ConfigBase subclass or Union containing ConfigBase.

zencfg.config.is_configbase_type(tp: Any) bool[source]#

Return True if ‘tp’ is a ConfigBase subclass or a Union that includes one.

gather_defaults#

Collects default values from a class and its inheritance hierarchy.

Contributing Guidelines#

  • Follow existing code style

  • Add tests for new features

  • Update documentation as needed

  • Open an issue before major changes