From 5e636989f098354ecbe0e6445047cbcc1a03d186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20DIDIER?= <73602526+sdidier-dev@users.noreply.github.com> Date: Mon, 18 Jul 2022 15:35:31 +0200 Subject: [PATCH 1/7] Fix typo in docs/api/#custom-tests --- docs/api.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index b2db5375c..e2c9bd526 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -751,8 +751,8 @@ Now it can be used in templates: {% endif %} Some decorators are available to tell Jinja to pass extra information to -the filter. The object is passed as the first argument, making the value -being filtered the second argument. +the test. The object is passed as the first argument, making the value +being tested the second argument. - :func:`pass_environment` passes the :class:`Environment`. - :func:`pass_eval_context` passes the :ref:`eval-context`. From c4bff4efee83a50f051a5f49015b21989c0d0fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20DIDIER?= <73602526+sdidier-dev@users.noreply.github.com> Date: Fri, 22 Jul 2022 17:47:56 +0200 Subject: [PATCH 2/7] Add in docs/switching/#loops little improvement for consistency --- docs/switching.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/switching.rst b/docs/switching.rst index caa35c368..a0ee530e7 100644 --- a/docs/switching.rst +++ b/docs/switching.rst @@ -84,7 +84,7 @@ In Django, the special variable for the loop context is called .. code-block:: django {% for item in items %} - {{ item }} + {{ forloop.counter }}. {{ item }} {% empty %} No items! {% endfor %} @@ -95,7 +95,7 @@ and the ``else`` block is used for no loop items. .. code-block:: jinja {% for item in items %} - {{ loop.index}}. {{ item }} + {{ loop.index }}. {{ item }} {% else %} No items! {% endfor %} From 9e1895f0e25bf7cb4fbcfe6fc2c75dba52ff74ec Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Aug 2022 23:18:35 +0000 Subject: [PATCH 3/7] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v2.34.0 → v2.37.3](https://github.com/asottile/pyupgrade/compare/v2.34.0...v2.37.3) - [github.com/asottile/reorder_python_imports: v3.3.0 → v3.8.2](https://github.com/asottile/reorder_python_imports/compare/v3.3.0...v3.8.2) - [github.com/PyCQA/flake8: 4.0.1 → 5.0.2](https://github.com/PyCQA/flake8/compare/4.0.1...5.0.2) - [github.com/peterdemin/pip-compile-multi: v2.4.5 → v2.4.6](https://github.com/peterdemin/pip-compile-multi/compare/v2.4.5...v2.4.6) --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2291f1d1d..795faee40 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,12 +3,12 @@ ci: autoupdate_schedule: monthly repos: - repo: https://github.com/asottile/pyupgrade - rev: v2.34.0 + rev: v2.37.3 hooks: - id: pyupgrade args: ["--py37-plus"] - repo: https://github.com/asottile/reorder_python_imports - rev: v3.3.0 + rev: v3.8.2 hooks: - id: reorder-python-imports args: ["--application-directories", "src"] @@ -18,12 +18,12 @@ repos: hooks: - id: black - repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 + rev: 5.0.2 hooks: - id: flake8 additional_dependencies: [flake8-bugbear] - repo: https://github.com/peterdemin/pip-compile-multi - rev: v2.4.5 + rev: v2.4.6 hooks: - id: pip-compile-multi-verify - repo: https://github.com/pre-commit/pre-commit-hooks From 9fde7eb82021da0bb016e1990753afd6b2d39386 Mon Sep 17 00:00:00 2001 From: Anton Topchii Date: Fri, 2 Sep 2022 15:11:15 +0200 Subject: [PATCH 4/7] Update pylons url in documentation (#1715) Update pylons homepage url in docs --- docs/integration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/integration.rst b/docs/integration.rst index b945fb352..d53fb52ba 100644 --- a/docs/integration.rst +++ b/docs/integration.rst @@ -91,4 +91,4 @@ this add this to ``config/environment.py``: config['pylons.strict_c'] = True -.. _Pylons: https://pylonshq.com/ +.. _Pylons: https://pylonsproject.org/ From c436c9f18fc515c29d21f15bbcb0bbaf0259a4db Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 2 Oct 2022 07:03:21 -0700 Subject: [PATCH 5/7] [pre-commit.ci] pre-commit autoupdate (#1716) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 795faee40..bbca538fb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,11 +14,11 @@ repos: args: ["--application-directories", "src"] additional_dependencies: ["setuptools>60.9"] - repo: https://github.com/psf/black - rev: 22.6.0 + rev: 22.8.0 hooks: - id: black - repo: https://github.com/PyCQA/flake8 - rev: 5.0.2 + rev: 5.0.4 hooks: - id: flake8 additional_dependencies: [flake8-bugbear] From 0a10079f33f09162fea1b0af4ede9ea505f1cb17 Mon Sep 17 00:00:00 2001 From: David Lord Date: Thu, 13 Oct 2022 09:08:56 -0700 Subject: [PATCH 6/7] update dev dependencies --- .pre-commit-config.yaml | 6 +++--- docs/templates.rst | 3 +-- requirements/dev.txt | 26 +++++++++++--------------- requirements/docs.txt | 16 ++++++++-------- requirements/tests.txt | 4 ++-- requirements/typing.txt | 4 ++-- src/jinja2/environment.py | 8 ++++---- 7 files changed, 31 insertions(+), 36 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bbca538fb..9c9ab1e9a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,18 +3,18 @@ ci: autoupdate_schedule: monthly repos: - repo: https://github.com/asottile/pyupgrade - rev: v2.37.3 + rev: v3.1.0 hooks: - id: pyupgrade args: ["--py37-plus"] - repo: https://github.com/asottile/reorder_python_imports - rev: v3.8.2 + rev: v3.8.4 hooks: - id: reorder-python-imports args: ["--application-directories", "src"] additional_dependencies: ["setuptools>60.9"] - repo: https://github.com/psf/black - rev: 22.8.0 + rev: 22.10.0 hooks: - id: black - repo: https://github.com/PyCQA/flake8 diff --git a/docs/templates.rst b/docs/templates.rst index 341d0e12f..86d01a6e3 100644 --- a/docs/templates.rst +++ b/docs/templates.rst @@ -1608,8 +1608,7 @@ The following functions are available in the global scope by default: .. versionadded:: 2.1 - .. method:: current - :property: + .. property:: current Return the current item. Equivalent to the item that will be returned next time :meth:`next` is called. diff --git a/requirements/dev.txt b/requirements/dev.txt index 470cc78fa..96a37927d 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -16,41 +16,37 @@ click==8.1.3 # via # pip-compile-multi # pip-tools -distlib==0.3.4 +distlib==0.3.6 # via virtualenv -filelock==3.7.1 +filelock==3.8.0 # via # tox # virtualenv -identify==2.5.1 +identify==2.5.6 # via pre-commit nodeenv==1.7.0 # via pre-commit -pep517==0.12.0 +pep517==0.13.0 # via build -pip-compile-multi==2.4.5 +pip-compile-multi==2.4.6 # via -r requirements/dev.in -pip-tools==6.8.0 +pip-tools==6.9.0 # via pip-compile-multi platformdirs==2.5.2 # via virtualenv -pre-commit==2.19.0 +pre-commit==2.20.0 # via -r requirements/dev.in pyyaml==6.0 # via pre-commit six==1.16.0 - # via - # tox - # virtualenv + # via tox toml==0.10.2 - # via - # pre-commit - # tox + # via pre-commit toposort==1.7 # via pip-compile-multi -tox==3.25.1 +tox==3.26.0 # via -r requirements/dev.in -virtualenv==20.15.1 +virtualenv==20.16.5 # via # pre-commit # tox diff --git a/requirements/docs.txt b/requirements/docs.txt index 9f1f1b307..fba4c8c6c 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -9,13 +9,13 @@ alabaster==0.7.12 # via sphinx babel==2.10.3 # via sphinx -certifi==2022.6.15 +certifi==2022.9.24 # via requests -charset-normalizer==2.1.0 +charset-normalizer==2.1.1 # via requests -docutils==0.18.1 +docutils==0.19 # via sphinx -idna==3.3 +idna==3.4 # via requests imagesize==1.4.1 # via sphinx @@ -29,17 +29,17 @@ packaging==21.3 # sphinx pallets-sphinx-themes==2.0.2 # via -r requirements/docs.in -pygments==2.12.0 +pygments==2.13.0 # via sphinx pyparsing==3.0.9 # via packaging -pytz==2022.1 +pytz==2022.4 # via babel requests==2.28.1 # via sphinx snowballstemmer==2.2.0 # via sphinx -sphinx==5.0.2 +sphinx==5.2.3 # via # -r requirements/docs.in # pallets-sphinx-themes @@ -61,5 +61,5 @@ sphinxcontrib-qthelp==1.0.3 # via sphinx sphinxcontrib-serializinghtml==1.1.5 # via sphinx -urllib3==1.26.9 +urllib3==1.26.12 # via requests diff --git a/requirements/tests.txt b/requirements/tests.txt index 753d04ab1..1b1aba388 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -5,7 +5,7 @@ # # pip-compile-multi # -attrs==21.4.0 +attrs==22.1.0 # via pytest iniconfig==1.1.1 # via pytest @@ -17,7 +17,7 @@ py==1.11.0 # via pytest pyparsing==3.0.9 # via packaging -pytest==7.1.2 +pytest==7.1.3 # via -r requirements/tests.in tomli==2.0.1 # via pytest diff --git a/requirements/typing.txt b/requirements/typing.txt index dc9f0508f..ee7e37641 100644 --- a/requirements/typing.txt +++ b/requirements/typing.txt @@ -5,11 +5,11 @@ # # pip-compile-multi # -mypy==0.961 +mypy==0.982 # via -r requirements/typing.in mypy-extensions==0.4.3 # via mypy tomli==2.0.1 # via mypy -typing-extensions==4.3.0 +typing-extensions==4.4.0 # via mypy diff --git a/src/jinja2/environment.py b/src/jinja2/environment.py index ea04e8b44..88b26662f 100644 --- a/src/jinja2/environment.py +++ b/src/jinja2/environment.py @@ -1253,7 +1253,7 @@ def _from_namespace( t.blocks = namespace["blocks"] # render function and module - t.root_render_func = namespace["root"] # type: ignore + t.root_render_func = namespace["root"] t._module = None # debug and loader helpers @@ -1349,7 +1349,7 @@ async def to_list() -> t.List[str]: ctx = self.new_context(dict(*args, **kwargs)) try: - yield from self.root_render_func(ctx) # type: ignore + yield from self.root_render_func(ctx) except Exception: yield self.environment.handle_exception() @@ -1532,7 +1532,7 @@ def __init__( " API you are using." ) - body_stream = list(template.root_render_func(context)) # type: ignore + body_stream = list(template.root_render_func(context)) self._body_stream = body_stream self.__dict__.update(context.get_exported()) @@ -1564,7 +1564,7 @@ def __init__(self, template: Template, undefined_to_none: bool) -> None: def __call__(self, *args: t.Any, **kwargs: t.Any) -> t.Optional[t.Any]: context = self._template.new_context(dict(*args, **kwargs)) - consume(self._template.root_render_func(context)) # type: ignore + consume(self._template.root_render_func(context)) rv = context.vars["result"] if self._undefined_to_none and isinstance(rv, Undefined): rv = None From b1bb29d292e5dbb37ba1116b26bcb1ab8d622dd5 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Wed, 12 Oct 2022 14:54:21 -0700 Subject: [PATCH 7/7] Show how {% filter %} can take filter arguments Closes #1732 --- docs/templates.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/templates.rst b/docs/templates.rst index 86d01a6e3..ad177419e 100644 --- a/docs/templates.rst +++ b/docs/templates.rst @@ -1015,6 +1015,9 @@ template data. Just wrap the code in the special `filter` section:: This text becomes uppercase {% endfilter %} +Filters that accept arguments can be called like this:: + + {% filter center(100) %}Center this{% endfilter %} .. _assignments: