Skip to content

htmltools 0.7.0

Latest

Choose a tag to compare

@schloerke schloerke released this 21 May 15:00
· 1 commit to main since this release
d3ba75c

Breaking changes

  • Tagifiable.tagify()'s return annotation is now Tagified, a new type alias for the union of fully-tagified shapes (TagifiedNode | float | None | Sequence[Tagified], mirroring TagChild). Custom .tagify() implementations annotated with bare TagList / Tag return types should switch to -> Tagified, or drop the annotation. Runtime behavior of correct implementations is unchanged. (#105, #116)

  • The result of .tagify() is now immutable. Calling .append, .extend, .insert, .add_class, __setitem__, or the context-manager with form on a tagified value raises AttributeError and is a static type error. Mutate on the buildable Tag / TagList side, then call .tagify() once to produce the render-ready result. (#116)

  • TagList.tagify() now raises TypeError at the boundary when a child's .tagify() returns un-tagified content (e.g. a bare TagList containing a still-Tagifiable object). The error names the offending class and slot index so buggy .tagify() implementations surface at the source. The render-time RuntimeError for the same family of violations has been clarified. (#7, #105, #112, #116)

New features

  • Exported the new tagified sibling classes TagifiedTag and TagifiedTagList. Use them in narrow annotations (def f(t: TagifiedTag): ...) and isinstance checks on .tagify() output. (#116)

  • Added is_tagified(x) for runtime distinguishability between buildable Tag / TagList and their tagified counterparts. Returns a TypeIs[...] so pyright narrows at call sites. (#116)

Dependencies

  • Bumped typing-extensions floor to >=4.12.0.

Other changes

  • Switched the contributor workflow to uv and reorganized Makefile targets. Run make setup (or make ai-setup) to bootstrap a dev environment, and make help to list available targets. pip install -e ".[dev,test]" no longer works since dev and test are now PEP 735 dependency groups; use uv sync --all-groups instead. (#107)

  • Replaced black, isort, and flake8 with ruff for linting and formatting. Run make format to auto-fix, or make check-format to verify. (#110)