Skip to content
Myr

Merge branch '3.1.x'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parents 953acd6, ae312b3 · Browse files · 17 files+98 added−82 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

17 files+98 added−82 removed

  • tests:+27 added−14 removed
  • other:+71 added−68 removed

17 files+98 added−82 removed

modified:docs/conf.py-2 removed
30 unmodified lines
31 ProjectLink("Donate", "https://palletsprojects.com/donate"),32 ProjectLink("PyPI Releases", "https://pypi.org/project/Jinja2/"),33 ProjectLink("Source Code", "https://github.com/pallets/jinja/"),34 ProjectLink("Issue Tracker", "https://github.com/pallets/jinja/issues/"),35 ProjectLink("Website", "https://palletsprojects.com/p/jinja/"),36 ProjectLink("Twitter", "https://twitter.com/PalletsTeam"),35 ProjectLink("Chat", "https://discord.gg/pallets"),36 ]37}38html_sidebars = {
13 unmodified lines
modified:requirements/build.txt+4 added-6 removed
3 unmodified lines
4# To update, run:5#6# pip-compile-multi7#8build==0.9.08build==0.10.09 # via -r requirements/build.in10packaging==23.010packaging==23.111 # via build12pep517==0.13.012pyproject-hooks==1.0.013 # via build14tomli==2.0.115 # via16 # build17 # pep51715 # via build
modified:requirements/dev.txt+16 added-16 removed
6 unmodified lines
7#8-r docs.txt9-r tests.txt10-r typing.txt11build==0.9.011build==0.10.012 # via pip-tools13cachetools==5.2.013cachetools==5.3.114 # via tox15cfgv==3.3.116 # via pre-commit17chardet==5.1.0
5 unmodified lines
23colorama==0.4.624 # via tox25distlib==0.3.626 # via virtualenv27filelock==3.9.027filelock==3.12.028 # via29 # tox30 # virtualenv31identify==2.5.1131identify==2.5.2432 # via pre-commit33nodeenv==1.7.033nodeenv==1.8.034 # via pre-commit35pep517==0.13.036 # via build37pip-compile-multi==2.6.135pip-compile-multi==2.6.336 # via -r requirements/dev.in39pip-tools==6.12.137pip-tools==6.13.038 # via pip-compile-multi41platformdirs==2.6.239platformdirs==3.5.140 # via41 # tox42 # virtualenv45pre-commit==2.21.043pre-commit==3.3.244 # via -r requirements/dev.in47pyproject-api==1.2.145pyproject-api==1.5.146 # via tox47pyproject-hooks==1.0.048 # via build49pyyaml==6.050 # via pre-commit51toposort==1.751toposort==1.1052 # via pip-compile-multi53tox==4.1.053tox==4.5.254 # via -r requirements/dev.in55virtualenv==20.17.155virtualenv==20.23.056 # via57 # pre-commit58 # tox59wheel==0.38.459wheel==0.40.060 # via pip-tools6162# The following packages are considered to be unsafe in a requirements file:63# pip
1 unmodified line
modified:requirements/docs.txt+14 added-16 removed
3 unmodified lines
4# To update, run:5#6# pip-compile-multi7#8alabaster==0.7.128alabaster==0.7.139 # via sphinx10babel==2.11.010babel==2.12.111 # via sphinx12certifi==2022.12.712certifi==2023.5.713 # via requests14charset-normalizer==2.1.114charset-normalizer==3.1.015 # via requests16docutils==0.1916docutils==0.20.117 # via sphinx18idna==3.419 # via requests20imagesize==1.4.121 # via sphinx22jinja2==3.1.223 # via sphinx24markupsafe==2.1.124markupsafe==2.1.225 # via jinja226packaging==22.026packaging==23.127 # via28 # pallets-sphinx-themes29 # sphinx30pallets-sphinx-themes==2.0.330pallets-sphinx-themes==2.1.031 # via -r requirements/docs.in32pygments==2.13.032pygments==2.15.133 # via sphinx34pytz==2022.735 # via babel36requests==2.28.134requests==2.31.035 # via sphinx36snowballstemmer==2.2.037 # via sphinx40sphinx==6.0.038sphinx==7.0.139 # via40 # -r requirements/docs.in41 # pallets-sphinx-themes42 # sphinx-issues43 # sphinxcontrib-log-cabinet44sphinx-issues==3.0.145 # via -r requirements/docs.in48sphinxcontrib-applehelp==1.0.246sphinxcontrib-applehelp==1.0.447 # via sphinx48sphinxcontrib-devhelp==1.0.249 # via sphinx52sphinxcontrib-htmlhelp==2.0.050sphinxcontrib-htmlhelp==2.0.151 # via sphinx52sphinxcontrib-jsmath==1.0.153 # via sphinx54sphinxcontrib-log-cabinet==1.0.1
1 unmodified line
56sphinxcontrib-qthelp==1.0.357 # via sphinx58sphinxcontrib-serializinghtml==1.1.559 # via sphinx62urllib3==1.26.1360urllib3==2.0.261 # via requests
modified:requirements/tests.txt+4 added-6 removed
3 unmodified lines
4# To update, run:5#6# pip-compile-multi7#8attrs==22.2.08exceptiongroup==1.1.19 # via pytest10exceptiongroup==1.1.010iniconfig==2.0.011 # via pytest12iniconfig==1.1.112packaging==23.113 # via pytest14packaging==22.015 # via pytest14pluggy==1.0.015 # via pytest18pytest==7.2.016pytest==7.3.117 # via -r requirements/tests.in18tomli==2.0.119 # via pytest
modified:requirements/typing.txt+3 added-3 removed
3 unmodified lines
4# To update, run:5#6# pip-compile-multi7#8mypy==0.9918mypy==1.3.09 # via -r requirements/typing.in10mypy-extensions==0.4.310mypy-extensions==1.0.011 # via mypy12tomli==2.0.113 # via mypy14typing-extensions==4.4.014typing-extensions==4.6.215 # via mypy
modified:scripts/generate_identifier_pattern.py+2 added-2 removed
27 unmodified lines
28 sequential code points.2930 Source: https://stackoverflow.com/a/4629241/40061731 """32 for _, b in itertools.groupby(enumerate(data), lambda x: ord(x[1]) - x[0]):33 lb = list(b)32 for _, g in itertools.groupby(enumerate(data), lambda x: ord(x[1]) - x[0]):33 lb = list(g)34 yield lb[0][1], lb[-1][1]353637def build_pattern(ranges):
37 unmodified lines
modified:src/jinja2/environment.py+1 added-1 removed
701 unmodified lines
702 method in.703704 .. versionadded:: 2.5705 """706 return compile(source, filename, "exec") # type: ignore706 return compile(source, filename, "exec")707708 @typing.overload709 def compile( # type: ignore710 self,
959 unmodified lines
modified:src/jinja2/nativetypes.py+1 added-1 removed
104 unmodified lines
105 ctx = self.new_context(dict(*args, **kwargs))106107 try:108 return self.environment_class.concat( # type: ignore109 self.root_render_func(ctx) # type: ignore109 self.root_render_func(ctx)110 )111 except Exception:112 return self.environment.handle_exception()113
17 unmodified lines
modified:src/jinja2/parser.py+8 added-6 removed
309 unmodified lines
310311 # enforce that required blocks only contain whitespace or comments312 # by asserting that the body, if not empty, is just TemplateData nodes313 # with whitespace data314 if node.required and not all(315 isinstance(child, nodes.TemplateData) and child.data.isspace()316 for body in node.body317 for child in body.nodes # type: ignore318 ):319 self.fail("Required blocks can only contain comments or whitespace")314 if node.required:315 for body_node in node.body:316 if not isinstance(body_node, nodes.Output) or any(317 not isinstance(output_node, nodes.TemplateData)318 or not output_node.data.isspace()319 for output_node in body_node.nodes320 ):321 self.fail("Required blocks can only contain comments or whitespace")322323 self.stream.skip_if("name:" + node.name)324 return node325
716 unmodified lines
modified:src/jinja2/utils.py+1 added-1 removed
180 unmodified lines
181182183def pformat(obj: t.Any) -> str:184 """Format an object using :func:`pprint.pformat`."""185 from pprint import pformat # type: ignore185 from pprint import pformat186187 return pformat(obj)188189
568 unmodified lines
modified:tests/test_filters.py+2 added
868 unmodified lines
869 assert t1.render() == t2.render() == "foo"870871 with pytest.raises(TemplateRuntimeError, match="No filter named 'f'"):872 t1.render(x=42)873874 with pytest.raises(TemplateRuntimeError, match="No filter named 'f'"):875 t2.render(x=42)
modified:tests/test_inheritance.py+25 added-14 removed
285 unmodified lines
286 def test_invalid_required(self, env):287 env = Environment(288 loader=DictLoader(289 {290 "default": "{% block x required %}data {# #}{% endblock %}",291 "default1": "{% block x required %}{% block y %}"292 "{% endblock %} {% endblock %}",293 "default2": "{% block x required %}{% if true %}"294 "{% endif %} {% endblock %}",295 "level1": "{% if default %}{% extends default %}"296 "{% else %}{% extends 'default' %}{% endif %}"297 "{%- block x %}CHILD{% endblock %}",290 "empty": "{% block x required %}{% endblock %}",291 "blank": "{% block x required %} {# c #}{% endblock %}",292 "text": "{% block x required %}data {# c #}{% endblock %}",293 "block": "{% block x required %}{% block y %}"294 "{% endblock %}{% endblock %}",295 "if": "{% block x required %}{% if true %}"296 "{% endif %}{% endblock %}",297 "top": "{% extends t %}{% block x %}CHILD{% endblock %}",298 }299 )300 )301 t = env.get_template("level1")301 t = env.get_template("top")302 assert t.render(t="empty") == "CHILD"303 assert t.render(t="blank") == "CHILD"304303 with pytest.raises(305 required_block_check = pytest.raises(306 TemplateSyntaxError,307 match="Required blocks can only contain comments or whitespace",306 ):307 assert t.render(default="default")308 assert t.render(default="default2")309 assert t.render(default="default3")308 )309310 with required_block_check:311 t.render(t="text")312313 with required_block_check:314 t.render(t="block")315316 with required_block_check:317 t.render(t="if")318319 def test_required_with_scope(self, env):320 env = Environment(321 loader=DictLoader(322 {
31 unmodified lines
354 }355 )356 )357 tmpl = env.get_template("child")358359 with pytest.raises(TemplateSyntaxError):360 tmpl.render(default="default1", seq=list(range(3)))361362 with pytest.raises(TemplateSyntaxError):363 tmpl.render(default="default2", seq=list(range(3)))364365366class TestBugFix:
50 unmodified lines
modified:.pre-commit-config.yaml+3 added-3 removed
1 unmodified line
2 autoupdate_branch: "3.1.x"3 autoupdate_schedule: monthly4repos:5 - repo: https://github.com/asottile/pyupgrade6 rev: v3.3.16 rev: v3.4.07 hooks:8 - id: pyupgrade9 args: ["--py37-plus"]10 - repo: https://github.com/asottile/reorder_python_imports
2 unmodified lines
13 - id: reorder-python-imports14 args: ["--application-directories", "src"]15 additional_dependencies: ["setuptools>60.9"]16 - repo: https://github.com/psf/black17 rev: 23.1.017 rev: 23.3.018 hooks:19 - id: black20 - repo: https://github.com/PyCQA/flake821 rev: 6.0.022 hooks:23 - id: flake824 additional_dependencies: [flake8-bugbear]25 - repo: https://github.com/peterdemin/pip-compile-multi26 rev: v2.6.126 rev: v2.6.327 hooks:28 - id: pip-compile-multi-verify29 - repo: https://github.com/pre-commit/pre-commit-hooks30 rev: v4.4.0
4 unmodified lines
modified:CHANGES.rst+9 added
7 unmodified lines
8- Use modern packaging metadata with ``pyproject.toml`` instead of ``setup.cfg``.9 :pr:`1793`101112Version 3.1.313-------------1415Unreleased1617- Fix compiler error when checking if required blocks in parent templates are18 empty. :pr:`1858`192021Version 3.1.222-------------2324Released 2022-04-28
969 unmodified lines
modified:pyproject.toml+5 added-3 removed
2 unmodified lines
3description = "A very fast and expressive template engine."4readme = "README.rst"5license = {text = "BSD-3-Clause"}6maintainers = [{name = "Pallets", email = "contact@palletsprojects.com"}]7authors = [{name = "Armin Ronacher", email = "armin.ronacher@active-4.com"}]7classifiers = [8 "Development Status :: 5 - Production/Stable",9 "Environment :: Web Environment",10 "Intended Audience :: Developers",
12 unmodified lines
23Documentation = "https://jinja.palletsprojects.com/"24Changes = "https://jinja.palletsprojects.com/changes/"25"Source Code" = "https://github.com/pallets/jinja/"26"Issue Tracker" = "https://github.com/pallets/jinja/issues/"28Twitter = "https://twitter.com/PalletsTeam"27Chat = "https://discord.gg/pallets"2829[project.optional-dependencies]30i18n = ["Babel>=2.7"]
8 unmodified lines
39version = {attr = "jinja2.__version__"}4041[tool.pytest.ini_options]42testpaths = ["tests"]45filterwarnings = ["error"]43filterwarnings = [44 "error",45 # change in Python 3.12 beta causes warning from inside pytest46 "ignore:ast:DeprecationWarning",47]4849[tool.coverage.run]50branch = true51source = ["jinja2", "tests"]
19 unmodified lines
modified:README.rst-2 removed
71 unmodified lines
72- Changes: https://jinja.palletsprojects.com/changes/73- PyPI Releases: https://pypi.org/project/Jinja2/74- Source Code: https://github.com/pallets/jinja/75- Issue Tracker: https://github.com/pallets/jinja/issues/76- Website: https://palletsprojects.com/p/jinja/77- Twitter: https://twitter.com/PalletsTeam76- Chat: https://discord.gg/pallets