feat: TagList.tagify() raises TypeError on un-tagified content#112
Merged
Conversation
When a child Tagifiable.tagify() returns a TagList whose own children include another un-tagified Tagifiable, the broken recursion previously surfaced as a confusing render-time RuntimeError far from the offending implementation. TagList.tagify() now checks the post-recursion list for any remaining bare Tagifiable (Tag and TagList excluded, since they are themselves Tagifiable but already-tagified shapes) and raises TypeError naming the offending class and slot index. The render-time RuntimeError in TagList.get_html_string() — kept as the fallback when the tree is mutated after .tagify() — now also names the un-tagified class and points at the likely cause. No public types or signatures change; the guards are purely runtime.
Collaborator
Author
|
Merging this as it's good behavior to have while we worry about true the typing vars in #106 |
This was referenced May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds runtime guards (only) from #106, with zero changes to type signatures:
TagList.tagify()now checks the post-recursion list for any remaining bareTagifiable(excludingTag/TagList, which are themselvesTagifiablebut already-tagified shapes) and raisesTypeErrornaming the offending class and slot index. This surfaces a broken.tagify()implementation at its source rather than later at render time.TagList.get_html_string()'s render-timeRuntimeError(kept as the fallback when the tree is mutated after.tagify()) now also names the offending class and hints at the likely cause.tests/test_tagify.pycovering both guards plus idempotence of.tagify().Explicitly excluded from #106:
Tagified/TagifiedNode/TagifiedTag/TagifiedTagListtype aliases.Tag/TagListbecomingGeneric[ChildT].cast(...)calls and# pyright: ignore[...]comments.Tagifiable.tagify()/Tag.tagify()return-type changes.typing_extensions>=4.7.0floor bump._jsx.py/_util.pytype-assertion-driven changes.tests/test_types.pystatic-type assertions.Test plan
uv run pytest— 82 passeduv run pyright htmltools tests— 0 errors, 0 warningsuv run ruff check/ruff format --check— clean