Settings

Theme

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

1 points by devstein 2 years ago · 0 comments · 1 min read


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!

No comments yet.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection