﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
25422	Type annotations in template tag functions crash	Thomas Orozco	nobody	"Using function annotations in a function decorated with e.g. {{{simple_tag}}} throws an error:

{{{#!python
======================================================================
ERROR: test_annotated_function (template_tests.test_custom.TemplateTagLoadingTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File ""/Users/thomas/dev/django/tests/template_tests/test_custom.py"", line 446, in test_annotated_function
    Template(ttext)
  File ""/Users/thomas/dev/django/django/template/base.py"", line 190, in __init__
    self.nodelist = engine.compile_string(template_string, origin)
  File ""/Users/thomas/dev/django/django/template/engine.py"", line 261, in compile_string
    return parser.parse()
  File ""/Users/thomas/dev/django/django/template/base.py"", line 341, in parse
    compiled_result = compile_func(self, token)
  File ""/Users/thomas/dev/django/django/template/defaulttags.py"", line 1159, in load
    lib = get_library(taglib)
  File ""/Users/thomas/dev/django/django/template/base.py"", line 1392, in get_library
    lib = import_library(taglib_module)
  File ""/Users/thomas/dev/django/django/template/base.py"", line 1331, in import_library
    mod = import_module(taglib_module)
  File ""/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/importlib/__init__.py"", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File ""<frozen importlib._bootstrap>"", line 986, in _gcd_import
  File ""<frozen importlib._bootstrap>"", line 969, in _find_and_load
  File ""<frozen importlib._bootstrap>"", line 958, in _find_and_load_unlocked
  File ""<frozen importlib._bootstrap>"", line 673, in _load_unlocked
  File ""<frozen importlib._bootstrap_external>"", line 662, in exec_module
  File ""<frozen importlib._bootstrap>"", line 222, in _call_with_frames_removed
  File ""/Users/thomas/dev/django/tests/template_tests/templatetags/annotated_tag_function.py"", line 7, in <module>
    def annotated_tag_function(val: int):
  File ""/Users/thomas/dev/django/django/template/base.py"", line 1189, in dec
    params, varargs, varkw, defaults = getargspec(func)
  File ""/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/inspect.py"", line 1044, in getargspec
    raise ValueError(""Function has keyword-only arguments or annotations""
ValueError: Function has keyword-only arguments or annotations, use getfullargspec() API which can support them
}}}

I have prepared a failing test case (and will file it in Github after creating this issue). It looks like this is fixed in 1.9 due to https://code.djangoproject.com/ticket/24979 

Backporting those changes would probably fix the issue, but if that's not your preferred solution, I'm happy to work on an alternate patch.

Cheers,"	Bug	closed	Template system	1.8	Normal	fixed			Unreviewed	0	0	0	0	0	0
