Skip to main content

YAML renderer for t-string structured data templates

Project description

yaml-tstring

YAML rendering for PEP 750 t-strings. Parsing and rendering happen in Rust; this package is the Python wrapper.

Requires Python 3.14+.

This package depends on tstring-bindings, a native PyO3 extension. On supported platforms, install from prebuilt wheels. Other environments require a local Rust 1.94.0 toolchain build.

API

render_data(template, profile="1.2.2")  # -> Python data (list for multi-doc)
render_text(template, profile="1.2.2")  # -> YAML text
render_result(template, profile="1.2.2")  # -> RenderResult (.text + .data)

Type alias: YamlProfile = Literal["1.2.2"]

Parsed template structure is cached per process using template.strings + profile as the key.

How it works

The Python Template is converted to a Rust token stream and parsed by an interpolation-aware YAML scanner/parser. Block mappings, block sequences, flow collections, scalar styles, anchors, aliases, and tags are all parsed explicitly in Rust with interpolation nodes preserved. saphyr handles data materialization and normalization.

Supported positions

  • mapping-key interpolation
  • plain, single-quoted, double-quoted, and block scalar assembly
  • anchor, alias, and tag interpolation (including verbatim !<...> tags)
  • block and flow collections, multi-document streams
  • directives, %TAG handles, explicit document markers
  • merge keys, complex keys, trailing commas in flow collections
  • YAML 1.2.2 escape sequences in double-quoted scalars

The full tested boundary is in the backend support matrix.

Limits

  • non-finite floats rejected
  • metadata fragments must be non-empty and whitespace-free
  • integers keep exact Python text (no silent float coercion)
  • values must be representable in the current YAML 1.2+ surface

Verify

uv sync --group dev
uv run --group dev pytest

See also

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yaml_tstring-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yaml_tstring-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file yaml_tstring-0.1.0.tar.gz.

File metadata

  • Download URL: yaml_tstring-0.1.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for yaml_tstring-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a71f296f583ce5409e6511a9db6406b33d23af36c7c2f874746d70d7a05f5a03
MD5 07c7813d8a735771fa5e323e4f08bd2e
BLAKE2b-256 bb338f3b3bc5f6b741aab1942b810d0d65b29e0165ec694c24ce296c8eaa8934

See more details on using hashes here.

Provenance

The following attestation bundles were made for yaml_tstring-0.1.0.tar.gz:

Publisher: publish-python.yml on koxudaxi/tstring-structured-data

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yaml_tstring-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: yaml_tstring-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for yaml_tstring-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a98f0254170721744c4da243f5b708acb795ab40769b8b52749a8a986fe751a
MD5 081ee88e21413f0a08ad211c2a7935dc
BLAKE2b-256 c61f0e6b553262e4c6a09168be94b6daebce5c8c777e523a1bff0a977bb3e4dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for yaml_tstring-0.1.0-py3-none-any.whl:

Publisher: publish-python.yml on koxudaxi/tstring-structured-data

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page