Can jinja produce typehints? #1997
-
Hi 👋 Can Jinja2 produce type hints? eg def foo(bar:int) -> float:
pass Im trying to modify a script to produce type hints (namely https://github.com/realitix/vulkan which I've forked at https://github.com/ItsCubeTime/vulkanpybindings ) : env = jinja2.Environment(
autoescape=False,
trim_blocks=True,
lstrip_blocks=True,
loader=jinja2.FileSystemLoader(HERE)
)
out_dir = path.join(HERE, path.pardir, 'vulkan')
generatedPySource=env.get_template('vulkan.template.py').render(model=model) Currently, all the functions are entirely without annotations, but it seems that the dict used to produce the template file stores types - its just that jinja seemingly ignores it? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Jinja will render whatever text is in the template. Yes, if you write a template that produces the output you showed, it will render it. I'm not clear what the question is beyond that. I don't see what it's "ignoring". |
Beta Was this translation helpful? Give feedback.
Jinja will render whatever text is in the template. Yes, if you write a template that produces the output you showed, it will render it. I'm not clear what the question is beyond that. I don't see what it's "ignoring".