Can jinja produce typehints? #1997
Answered
by
davidism
ItsCubeTime
asked this question in
Q&A
|
Hi 👋 Can Jinja2 produce type hints? eg def foo(bar:int) -> float:
passIm 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? |
Answered by
davidism
Jun 9, 2024
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". |
0 replies
Answer selected by
ItsCubeTime
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to 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".