Registry / serialization / hiyapyco

hiyapyco

JSON →
library0.7.0pypypi✓ verified 84d ago

HiYaPyCo is a Python library (current version 0.7.0) that facilitates hierarchical overlay and merging of configuration files written in YAML. It supports multiple merge methods, including deep merge, and features variable interpolation using Jinja2. The library is actively maintained with regular releases. [1, 2, 3]

pip install hiyapyco
INSTALL
IMPORT
SIG · HIYAPYCO
H
hiyapyco
serializationpythonv0.7.0
Install
1.9s avg
Import
272ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.7.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.275s · 21.2MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.9s · import 0.270s · 22MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

hiyapyco
import hiyapyco

This quickstart demonstrates loading and merging two YAML documents provided as strings. It uses `hiyapyco.METHOD_MERGE` for a deep merge and enables Jinja2 interpolation to resolve variables like `{{ first }}`. The resulting merged configuration is then pretty-printed. [1, 3]

import hiyapyco import pprint yaml1_str = """ first: first element second: xxx deep: k1: - 1 - 2 """ yaml2_str = """ second: again {{ first }} deep: k1: - 4 - 6 k2: - 3 - 6 """ # Load and merge YAML documents from strings # METHOD_MERGE performs a deep merge. # interpolate=True enables Jinja2 variable substitution. conf = hiyapyco.load( [yaml1_str, yaml2_str], method=hiyapyco.METHOD_MERGE, interpolate=True ) pprint.pprint(conf) # Example of dumping the merged configuration back to YAML # print(hiyapyco.dump(conf, default_flow_style=False))
Debug
Known issues
breakingPython 2 support was officially dropped in version 0.5.0. Projects still using Python 2 must use an older version of hiyapyco (pre-0.5.0). [4]
fix
Upgrade to Python 3 or pin hiyapyco version to <0.5.0.
affects: < 0.5.0
gotchaWhen using Jinja2 interpolation, if `StrictUndefined` is configured for the Jinja2 environment (either explicitly or via default settings for certain operations), referencing an undefined variable in the YAML will raise a `hiyapyco.HiYaPyCoImplementationException` wrapped around a `jinja2.UndefinedError`. [1]
fix
Ensure all interpolated variables are defined, or set `hiyapyco.jinja2env = Environment(undefined=DebugUndefined)` before loading to make undefined variables appear as empty strings without errors. [1]
affects: All versions with Jinja2 interpolation
gotchaBy default, lists are replaced rather than merged when combining YAML files. To merge lists of dictionaries, you must explicitly set `mergelists=True` or use `method=hiyapyco.METHOD_MERGE`. Simple lists are concatenated with `METHOD_MERGE`. [1, 3, 7]
fix
Pass `mergelists=True` or `method=hiyapyco.METHOD_MERGE` to the `hiyapyco.load()` function to enable list merging behavior. Example: `hiyapyco.load('file1.yaml', 'file2.yaml', method=hiyapyco.METHOD_MERGE, mergelists=True)`.
affects: All versions
gotchaThe `none_behavior` parameter (introduced in 0.7.0) defaults to `NONE_BEHAVIOR_DEFAULT`, which attempts to merge `None` and may fail. If `None` values should override or be ignored, this needs to be explicitly set. [3]
fix
Specify `none_behavior=hiyapyco.NONE_BEHAVIOR_OVERRIDE` (None overrides other values) or `none_behavior=hiyapyco.NONE_BEHAVIOR_IGNORE` (None is ignored) when calling `hiyapyco.load()`. [3]
affects: >= 0.7.0
Errors
Common errors & fixes
ImportError: No module named 'yaml' (or ImportError: No module named yaml)
The underlying YAML parsing library, PyYAML, is a required dependency but was not installed in the environment. This often occurs when `hiyapyco` is installed without its dependencies being correctly resolved. [8]
fix
Ensure PyYAML is installed by running `pip install PyYAML` or simply reinstalling `hiyapyco` to allow pip to resolve dependencies: `pip install hiyapyco`.
hiyapyco.HiYaPyCoImplementationException: '{{ my_undefined_var }}' - UndefinedError: 'my_undefined_var' is undefined
This error occurs during Jinja2 interpolation when a variable referenced in the YAML (e.g., `{{ my_undefined_var }}`) does not exist in the provided context, and the Jinja2 environment is configured for strict undefined variable handling. [1]
fix
Provide a value for the missing variable or configure `hiyapyco`'s Jinja2 environment to handle undefined variables gracefully, e.g., by setting `hiyapyco.jinja2env = Environment(undefined=DebugUndefined)` before loading YAML. [1]
Lists are replaced instead of being merged when loading multiple YAML files.
By default, hiyapyco's load operation replaces entire lists from earlier files with lists from later files, rather than merging their contents. [7]
fix
To achieve list merging (concatenation for simple lists, deep merge for lists of dicts), use `method=hiyapyco.METHOD_MERGE` and/or `mergelists=True` in your `hiyapyco.load` call. For example: `hiyapyco.load('file1.yaml', 'file2.yaml', method=hiyapyco.METHOD_MERGE, mergelists=True)`.
Upgrade
Version history
0.7.0latest on PyPI · released Oct 20, 2024
Audit
Dependencies
PyYAMLrequiredRequired for parsing and dumping YAML files.
Jinja2requiredRequired for variable interpolation within YAML configuration files.
Agent activity
6 hits · last 30 days
node
6
Resources
hiyapyco — pip install hiyapyco · libregistry