diff --git a/django-stubs/template/library.pyi b/django-stubs/template/library.pyi index fddeaa381..f9d146723 100644 --- a/django-stubs/template/library.pyi +++ b/django-stubs/template/library.pyi @@ -29,7 +29,7 @@ class Library: @overload def filter(self, name: str | None = None, filter_func: None = None, **flags: Any) -> Callable[[_C], _C]: ... @overload - def simple_tag(self, func: _C) -> _C: ... + def simple_tag(self, func: _C, takes_context: bool | None = None, name: str | None = None) -> _C: ... @overload def simple_tag(self, takes_context: bool | None = None, name: str | None = None) -> Callable[[_C], _C]: ... def inclusion_tag( diff --git a/tests/typecheck/template/test_library.yml b/tests/typecheck/template/test_library.yml index b3fd4dde0..2be31d925 100644 --- a/tests/typecheck/template/test_library.yml +++ b/tests/typecheck/template/test_library.yml @@ -57,6 +57,16 @@ reveal_type(some_function) # N: Revealed type is "def (value: builtins.int) -> builtins.int" +- case: register_simple_tag_via_call + main: | + from django import template + register = template.Library() + + def f(s: str) -> str: + return s * 2 + + reveal_type(register.simple_tag(f, name='double')) # N: Revealed type is "def (s: builtins.str) -> builtins.str" + - case: register_tag_no_args main: | from django import template