Ask HN: Is There a Way to Make Jinja Templates Type Safe via Mypy?
Hi HN, we use Jinja templates to manage our prompts at Dosu (https://dosu.dev/).
We use MyPy to ensure type-safety across our entire codebase, but we do not have coverage on Jinja template variables.
We want to know if someone either
(a) forgets to pass a required template variable to a Jinja template (b) passes a name of a template variable that doesn't exist
We already get these errors at runtime with Jinja, but want to know if there is a way to statically check for this.
I'm curious if anyone has run into this before or has suggestions for type-safe templating in Python.
Thanks!
Hi HN, we use Jinja templates to manage our prompts at Dosu (https://dosu.dev/).
We use MyPy to ensure type-safety across our entire codebase, but we do not have coverage on Jinja template variables.
We want to know if someone either
(a) forgets to pass a required template variable to a Jinja template (b) passes a name of a template variable that doesn't exist
We already get these errors at runtime with Jinja, but want to know if there is a way to statically check for this.
I'm curious if anyone has run into this before or has suggestions for type-safe templating in Python.
Thanks!