Skip to content

Commit

Permalink
cherry-pick upstream: fix function overload of Library.simple_tag (#26)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Sottile <[email protected]>
  • Loading branch information
asottile-sentry and asottile authored Oct 4, 2024
1 parent bfcb743 commit 57bdf0f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django-stubs/template/library.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions tests/typecheck/template/test_library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 57bdf0f

Please sign in to comment.