Ask HN: Is There a Way to Make Jinja Templates Type Safe via Mypy?

1 points by devstein ↗ HN
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!

0 comments

[ 2.7 ms ] story [ 12.5 ms ] thread

No comments yet.