Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cherry-pick upstream: fix function overload of Library.simple_tag #26

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading