Makes use of typing.ParamSpec in Library decorators to allow decorated functions to preserve their type information.
Example:
register = template.Library()
@register.filter
def plain_text_quote(value: str):
"""Prefix each line in value with "> " to "quote" it in plain-text email bodies."""
return indent(value, "> ", lambda _: True)
result = plain_text_quote("foo")
result # <- inferred type is `str`
The docorators have complex relationships between their arguments and return types, so they are overloaded.
Makes use of
typing.ParamSpec
inLibrary
decorators to allow decorated functions to preserve their type information.Example:
The docorators have complex relationships between their arguments and return types, so they are overloaded.
Implementation reference