Registry / serialization / yte
library1.9.4pypypi✓ verified 84d ago

YTE is a template engine for the YAML format that leverages YAML's inherent structure to embed and evaluate Python expressions dynamically. This allows for conditional logic, loops, and arbitrary Python code directly within YAML documents, rendering them into plain YAML. It aims to provide a more 'YAML-native' templating experience compared to general-purpose engines like Jinja2. The library is currently at version 1.9.4 and is actively maintained.

pip install yte
INSTALL
IMPORT
SIG · YTE
Y
yte
serializationpythonv1.9.4
Install
1.8s avg
Import
153ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.9.4 · 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.920 runs
installs and imports cleanly · install 0.0s · import 0.154s · 20.2MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.8s · import 0.151s · 21MB
19MB installed
● package 19MB
Code
Verified usage

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

process_yaml
from yte import process_yaml
import yte.process_yaml
The primary function to process YAML templates is directly available under the 'yte' package, not a submodule 'yte.process_yaml'.

This quickstart demonstrates how to use `process_yaml` to render a YAML template containing embedded Python expressions. Expressions are prefixed with `?` and are evaluated in the provided context.

from yte import process_yaml import os # Example YAML content with YTE expressions yaml_template = """ name: John Doe age: ? 30 + 5 # Simple Python expression is_adult: ? age > 18 items: ? for i in range(2): - id: ? i + 1 value: Item ? i + 1 """ # Context (variables) for the template. In a real scenario, this might come from # a file, environment variables, or a Python dictionary. context = { "username": os.environ.get('YTE_USERNAME', 'guest') } processed_yaml = process_yaml(yaml_template, context=context) print(processed_yaml)
yte --version
Debug
Known issues
gotchaYTE uses '?' as the prefix for Python expressions within YAML. This is a non-standard YAML syntax extension and might conflict with YAML linters or other parsers not aware of YTE.
fix
Be aware of the '?' prefix for expressions and ensure your tooling is compatible or configure it to ignore these YTE-specific constructs. YTE templates are still valid YAML, where '?' expressions are treated as strings by standard parsers.
affects: All versions
breakingThere have been reported compatibility issues with Python 3.12 regarding the availability of for-loop variables for substitution within YTE templates. This may lead to unexpected behavior or failures.
fix
If encountering issues on Python 3.12, check the YTE GitHub issues for a resolution or consider using Python 3.11 or earlier until a fix is released. Review template logic, especially variable scoping within loops.
affects: Potentially 1.9.x on Python 3.12
gotchaYTE expressions are raw Python code. Any variable referenced within an expression (e.g., `? age > 18`) must be explicitly passed in the `context` dictionary to `process_yaml` or be a built-in Python function/value. Undefined variables will raise a `NameError`.
fix
Ensure all variables used in YTE expressions are present in the `context` dictionary passed to `process_yaml`. Thoroughly test templates for missing variable definitions.
affects: All versions
Errors
Common errors & fixes
NameError: name 'my_variable' is not defined
A Python expression within the YAML template (e.g., `? my_variable + 1`) is trying to use a variable that was not provided in the `context` dictionary when `process_yaml` was called.
fix
Pass `my_variable` and its value in the `context` dictionary to the `process_yaml` function. For example: `process_yaml(template, context={'my_variable': 10})`.
SyntaxError: invalid syntax
The Python expression following a `?` in the YAML template contains invalid Python syntax, or a Python-specific construct (like `for` or `if`) is malformed.
fix
Carefully review the Python expression within the YAML template. Ensure correct indentation for blocks, proper closing of parentheses/brackets, and adherence to Python syntax rules. Use a Python linter or IDE to validate the expression in isolation if needed.
TypeError: unsupported operand type(s) for +: 'int' and 'str'
A Python expression is attempting an operation (e.g., addition) between incompatible data types (e.g., an integer and a string), which is common when template variables have unexpected types.
fix
Explicitly cast variables to the correct type within the YTE expression (e.g., `? int(item_count) + 1`) or ensure the `context` dictionary provides variables with the expected types.
Upgrade
Version history
1.9.4latest on PyPI · released Nov 27, 2025
Audit
Dependencies
PythonrequiredYTE requires Python 3.8 or newer, but not Python 4.0 or newer.
Agent activity
64 hits · last 30 days
node
58
OpenAI (training)
1
Resources
yte — pip install yte · libregistry