From c5d00407b39f2fed6669eb15dd3f26dbf7cd4a7d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Fri, 16 May 2025 09:28:03 +0000 Subject: [PATCH] [pre-commit.ci lite] apply automatic fixes --- src/flask/sansio/app.py | 20 ++++++++++---------- tests/test_template_filters.py | 6 ++++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/flask/sansio/app.py b/src/flask/sansio/app.py index b4bb6639..d3ddde9b 100644 --- a/src/flask/sansio/app.py +++ b/src/flask/sansio/app.py @@ -32,7 +32,7 @@ from .scaffold import _endpoint_from_view_func from .scaffold import find_package from .scaffold import Scaffold from .scaffold import setupmethod -from functools import wraps + if t.TYPE_CHECKING: # pragma: no cover from werkzeug.wrappers import Response as BaseResponse @@ -665,18 +665,18 @@ class App(Scaffold): self, name: str | None = None ) -> t.Callable[[T_template_filter], T_template_filter]: """A decorator that is used to register custom template filters. - You can use this with or without parentheses. Example:: + You can use this with or without parentheses. Example:: - @app.template_filter - def double(x): - return x * 2 + @app.template_filter + def double(x): + return x * 2 - @app.template_filter() - def reverse(s): - return s[::-1] + @app.template_filter() + def reverse(s): + return s[::-1] - :param name: the optional name of the filter, otherwise the - function name will be used. + :param name: the optional name of the filter, otherwise the + function name will be used. """ if callable(name): diff --git a/tests/test_template_filters.py b/tests/test_template_filters.py index 7dda15f8..9b8b4e8d 100644 --- a/tests/test_template_filters.py +++ b/tests/test_template_filters.py @@ -1,5 +1,6 @@ -import pytest -from flask import Flask, render_template_string +from flask import Flask +from flask import render_template_string + def test_template_filter_without_parentheses(): app = Flask(__name__) @@ -12,6 +13,7 @@ def test_template_filter_without_parentheses(): output = render_template_string("{{ 2 | double }}") assert output == "4" + def test_template_filter_with_parentheses(): app = Flask(__name__)