Skip to content

Commit 57bdf0f

Browse files
cherry-pick upstream: fix function overload of Library.simple_tag (#26)
Co-authored-by: Anthony Sottile <[email protected]>
1 parent bfcb743 commit 57bdf0f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

django-stubs/template/library.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Library:
2929
@overload
3030
def filter(self, name: str | None = None, filter_func: None = None, **flags: Any) -> Callable[[_C], _C]: ...
3131
@overload
32-
def simple_tag(self, func: _C) -> _C: ...
32+
def simple_tag(self, func: _C, takes_context: bool | None = None, name: str | None = None) -> _C: ...
3333
@overload
3434
def simple_tag(self, takes_context: bool | None = None, name: str | None = None) -> Callable[[_C], _C]: ...
3535
def inclusion_tag(

tests/typecheck/template/test_library.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@
5757
5858
reveal_type(some_function) # N: Revealed type is "def (value: builtins.int) -> builtins.int"
5959
60+
- case: register_simple_tag_via_call
61+
main: |
62+
from django import template
63+
register = template.Library()
64+
65+
def f(s: str) -> str:
66+
return s * 2
67+
68+
reveal_type(register.simple_tag(f, name='double')) # N: Revealed type is "def (s: builtins.str) -> builtins.str"
69+
6070
- case: register_tag_no_args
6171
main: |
6272
from django import template

0 commit comments

Comments
 (0)