From 18afca24b0cf837d07d447403cfc2bece57df32a Mon Sep 17 00:00:00 2001 From: Gabgobie <105999094+Gabgobie@users.noreply.github.com> Date: Wed, 25 Feb 2026 18:24:27 +0100 Subject: [PATCH] Replaces TypeVar "F" with type alias FilterFunction and applies the same fix for TESTS --- src/jinja2/filters.py | 4 ++-- src/jinja2/tests.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/jinja2/filters.py b/src/jinja2/filters.py index 2bcba4fb..0be0311a 100644 --- a/src/jinja2/filters.py +++ b/src/jinja2/filters.py @@ -41,7 +41,7 @@ if t.TYPE_CHECKING: pass -F = t.TypeVar("F", bound=t.Callable[..., t.Any]) +FilterFunction = t.Callable[..., t.Any] K = t.TypeVar("K") V = t.TypeVar("V") @@ -1815,7 +1815,7 @@ async def async_select_or_reject( yield item -FILTERS = { +FILTERS: t.Dict[str, FilterFunction] = { "abs": abs, "attr": do_attr, "batch": do_batch, diff --git a/src/jinja2/tests.py b/src/jinja2/tests.py index 1a59e370..17e21d36 100644 --- a/src/jinja2/tests.py +++ b/src/jinja2/tests.py @@ -12,6 +12,9 @@ if t.TYPE_CHECKING: from .environment import Environment +TestFunction = t.Callable[..., t.Any] + + def test_odd(value: int) -> bool: """Return true if the variable is odd.""" return value % 2 == 1 @@ -213,7 +216,7 @@ def test_in(value: t.Any, seq: t.Container[t.Any]) -> bool: return value in seq -TESTS = { +TESTS: t.Dict[str, TestFunction] = { "odd": test_odd, "even": test_even, "divisibleby": test_divisibleby,