Skip to main content

TOML renderer for t-string structured data templates

Project description

toml-tstring

TOML 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.1")  # -> Python data
render_text(template, profile="1.1")  # -> TOML text
render_result(template, profile="1.1")  # -> RenderResult (.text + .data)

Type alias: TomlProfile = Literal["1.0", "1.1"]

Parsed template structure is cached per process using template.strings + profile as the key. Use profile="1.0" when you need the stricter TOML 1.0 behavior.

How it works

The Python Template is converted to a Rust token stream and parsed into TOML nodes -- assignments, key paths, headers, arrays, inline tables, literals, and string families all become explicit nodes with interpolation preserved. Rendering is driven by the parsed node type. The Rust toml crate handles value materialization and normalization.

Supported positions

  • whole-value, key, dotted-key, table-header, and array-of-table interpolation
  • string-fragment interpolation across all four TOML string types
  • nested arrays, inline tables, and array-of-table sections
  • integer forms (hex, binary, octal), special floats (inf, nan)
  • datetime, date, and time values

Limits

  • None rejected (TOML has no null)
  • offset time values rejected
  • integers must fit signed 64-bit range
  • values must be TOML-representable

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

toml_tstring-0.2.1.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.

toml_tstring-0.2.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file toml_tstring-0.2.1.tar.gz.

File metadata

  • Download URL: toml_tstring-0.2.1.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 toml_tstring-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a83ad8a90b788afa87b2c834c311801a7756043509305b42ed5e55e283d53902
MD5 de614a996d126d1560ead9a1b98336ee
BLAKE2b-256 23d5f43b635d43c2a1de8449527f8ae224f758b0fc66c9562107a88db0cab5a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for toml_tstring-0.2.1.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 toml_tstring-0.2.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for toml_tstring-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4efc6f2f85e8bbee11011ac96d680497fdcd2b45ce8b2d98de999873f4c15d8f
MD5 1cf72d6ed2331c242f96f4a9f680fe18
BLAKE2b-256 9c20df38faef46b59f61f8eb69be4a788e35cc0d121494c68347b9baef438e0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for toml_tstring-0.2.1-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