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.2.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.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for toml_tstring-0.2.2.tar.gz
Algorithm Hash digest
SHA256 4e0899899be4fb3d27c7cedb3b1bd584c53db5ef3221479ad308bc3fec574f25
MD5 9ceceb6c73031736ed842c0ee7b2efef
BLAKE2b-256 83ee50d4e338edf984d66b2c5706e4fabe0e3eff88c7dabe8e8c8e3e1abbd84d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: toml_tstring-0.2.2-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.12

File hashes

Hashes for toml_tstring-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 10f10c35bf28721e3374a5b3047a5d637393ed14af4bb3c63e07330d754ee89b
MD5 dc86e3d1f578f876365bee74ad7dcd38
BLAKE2b-256 19cc30fa0293858da7fdb18bece0fd71e686cdf99d0a505fcce6a5290d07165b

See more details on using hashes here.

Provenance

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