{"id":30021915,"url":"https://github.com/abilian/tstrings-backport","last_synced_at":"2025-08-06T03:37:51.860Z","repository":{"id":308162924,"uuid":"1031843034","full_name":"abilian/tstrings-backport","owner":"abilian","description":"Backport of t-strings (PEP 750)","archived":false,"fork":false,"pushed_at":"2025-08-04T12:48:42.000Z","size":152,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-04T16:49:17.340Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abilian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-04T12:15:56.000Z","updated_at":"2025-08-04T12:48:45.000Z","dependencies_parsed_at":"2025-08-04T16:59:57.055Z","dependency_job_id":null,"html_url":"https://github.com/abilian/tstrings-backport","commit_stats":null,"previous_names":["abilian/tstrings-backport"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/abilian/tstrings-backport","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abilian%2Ftstrings-backport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abilian%2Ftstrings-backport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abilian%2Ftstrings-backport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abilian%2Ftstrings-backport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abilian","download_url":"https://codeload.github.com/abilian/tstrings-backport/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abilian%2Ftstrings-backport/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268954139,"owners_count":24335179,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-05T02:00:12.334Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-06T03:37:49.786Z","updated_at":"2025-08-06T03:37:51.851Z","avatar_url":"https://github.com/abilian.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tstrings: PEP 750-style Template Strings for Python \u003c 3.14\n\nThis package provides a backport of the new [PEP 750](https://peps.python.org/pep-0750/) \"t-string\" template string syntax, for use with Python versions **before 3.14**.\n\n## Usage\n\nInstead of the new syntax `t\"...\"` (which is only available in Python 3.14+), use the function call form:\n\n```python\nfrom tstrings import t\n\nname = \"World\"\ntpl = t(\"Hello, {name}!\")\nprint(tpl.strings)         # (\"Hello, \", \"!\")\nprint(tpl.interpolations)  # (Interpolation(value=\"World\", expression=\"name\", ...),)\n```\n\nThe returned object is a `Template` with `.strings` and `.interpolations` attributes, closely matching the PEP 750 API.\n\n## Features\n\n- **String interpolation**: Supports `{expr}` expressions, including complex expressions.\n- **Debug specifier**: `{var=}` and `{var=:.2f}` forms, as in f-strings.\n- **Conversion specifiers**: `{val!r}`, `{val!s}`, `{val!a}`.\n- **Format specifiers**: `{num:.2f}`.\n- **Multiline expressions**: Supported.\n- **Error handling**: Raises `NameError` or `SyntaxError` for invalid expressions, as in f-strings (but at runtime, not at compile time).\n- **PEP 750 API**: Returns `Template` and `Interpolation` dataclasses matching the PEP.\n\n## Limitations\n\n- **No t-string literal syntax**: You must use `t(\"...\")`, not `t\"...\"`.\n- **No support for all edge cases**: Some advanced t-string edge cases may not be fully supported.\n\n## Examples\n\n```python\nfrom tstrings import t\n\nname = \"\"\nvalue = 1\nnum = 3.1415\nobj = {}\ndata = [1, 2, 3]\n\n# Simple\ntpl = t(\"Hello, {name}!\")\n# Debug\ntpl = t(\"{value=}\")\n# Format\ntpl = t(\"{num:.2f}\")\n# Conversion\ntpl = t(\"{obj!r}\")\n# Multiline\ntpl = t(\"\"\"\n    {sum(data)}\n\"\"\")\n```\n\n## Development \u0026 Testing\n\nInstall with `uv sync` and activate the virtualenv (`. .venv/bin/activate` or similar).\n\nRun the test suite with:\n\n```sh\nnox\n```\n\nor just:\n\n```sh\npytest\n```\n\nSee `tests/test_all.py` for coverage of all supported features.\n\nTests also include the tdom source code (modified for pre-3.14 syntax) and test suite.\n\n## How to help\n\nThis was hacked together in less than 2 hours. If you find it useful, please consider contributing fixes, improvements, or documentation!\n\nPull requests and issues are welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabilian%2Ftstrings-backport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabilian%2Ftstrings-backport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabilian%2Ftstrings-backport/lists"}