from string.templatelib import Template
def execute(query: Template)
Should allow for static analysis to prevent this issue if you run mypy as part of your pr process.That would be in addition to doing any runtime checks.
from string.templatelib import Template
def execute(query: Template)
Should allow for static analysis to prevent this issue if you run mypy as part of your pr process.That would be in addition to doing any runtime checks.
def execute(query: Union[str, Template]):
Maybe because they want their execute function to be backwards compatible, or just because they really do want to allow either raw strings are a template string.I’d consider that an invalid use case:
1. You can create a template string without placeholders.
2. Even if the caller does need to pass in a string (because they’re executing from a file, or t-strings don’t support e.g. facetting) then they can just… wrap the string in a template explicitly.