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
Provenance
- Commit
81a2384- Tree
d9d7eaf- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent 1
953acd6- Parent 2
ae312b3
17 files changed+98 added−82 removed
modified:docs/conf.py-2 removed
30 unmodified lines31 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 }38 html_sidebars = {13 unmodified linesmodified:requirements/build.txt+4 added-6 removed
3 unmodified lines4 # To update, run:5 #6 # pip-compile-multi7 #8-build==0.9.08+build==0.10.09 # via -r requirements/build.in10-packaging==23.010+packaging==23.111 # via build12-pep517==0.13.012+pyproject-hooks==1.0.013 # via build14 tomli==2.0.115- # via16- # build17- # pep51715+ # via buildmodified:requirements/dev.txt+16 added-16 removed
6 unmodified lines7 #8 -r docs.txt9 -r tests.txt10 -r typing.txt11-build==0.9.011+build==0.10.012 # via pip-tools13-cachetools==5.2.013+cachetools==5.3.114 # via tox15 cfgv==3.3.116 # via pre-commit17 chardet==5.1.05 unmodified lines23 colorama==0.4.624 # via tox25 distlib==0.3.626 # via virtualenv27-filelock==3.9.027+filelock==3.12.028 # via29 # tox30 # virtualenv31-identify==2.5.1131+identify==2.5.2432 # via pre-commit33-nodeenv==1.7.033+nodeenv==1.8.034 # via pre-commit35-pep517==0.13.036- # via build37-pip-compile-multi==2.6.135+pip-compile-multi==2.6.336 # via -r requirements/dev.in39-pip-tools==6.12.137+pip-tools==6.13.038 # via pip-compile-multi41-platformdirs==2.6.239+platformdirs==3.5.140 # via41 # tox42 # virtualenv45-pre-commit==2.21.043+pre-commit==3.3.244 # via -r requirements/dev.in47-pyproject-api==1.2.145+pyproject-api==1.5.146 # via tox47+pyproject-hooks==1.0.048+ # via build49 pyyaml==6.050 # via pre-commit51-toposort==1.751+toposort==1.1052 # via pip-compile-multi53-tox==4.1.053+tox==4.5.254 # via -r requirements/dev.in55-virtualenv==20.17.155+virtualenv==20.23.056 # via57 # pre-commit58 # tox59-wheel==0.38.459+wheel==0.40.060 # via pip-tools61 62 # The following packages are considered to be unsafe in a requirements file:63 # pip1 unmodified linemodified:requirements/docs.txt+14 added-16 removed
3 unmodified lines4 # To update, run:5 #6 # pip-compile-multi7 #8-alabaster==0.7.128+alabaster==0.7.139 # via sphinx10-babel==2.11.010+babel==2.12.111 # via sphinx12-certifi==2022.12.712+certifi==2023.5.713 # via requests14-charset-normalizer==2.1.114+charset-normalizer==3.1.015 # via requests16-docutils==0.1916+docutils==0.20.117 # via sphinx18 idna==3.419 # via requests20 imagesize==1.4.121 # via sphinx22 jinja2==3.1.223 # via sphinx24-markupsafe==2.1.124+markupsafe==2.1.225 # via jinja226-packaging==22.026+packaging==23.127 # via28 # pallets-sphinx-themes29 # sphinx30-pallets-sphinx-themes==2.0.330+pallets-sphinx-themes==2.1.031 # via -r requirements/docs.in32-pygments==2.13.032+pygments==2.15.133 # via sphinx34-pytz==2022.735- # via babel36-requests==2.28.134+requests==2.31.035 # via sphinx36 snowballstemmer==2.2.037 # via sphinx40-sphinx==6.0.038+sphinx==7.0.139 # via40 # -r requirements/docs.in41 # pallets-sphinx-themes42 # sphinx-issues43 # sphinxcontrib-log-cabinet44 sphinx-issues==3.0.145 # via -r requirements/docs.in48-sphinxcontrib-applehelp==1.0.246+sphinxcontrib-applehelp==1.0.447 # via sphinx48 sphinxcontrib-devhelp==1.0.249 # via sphinx52-sphinxcontrib-htmlhelp==2.0.050+sphinxcontrib-htmlhelp==2.0.151 # via sphinx52 sphinxcontrib-jsmath==1.0.153 # via sphinx54 sphinxcontrib-log-cabinet==1.0.11 unmodified line56 sphinxcontrib-qthelp==1.0.357 # via sphinx58 sphinxcontrib-serializinghtml==1.1.559 # via sphinx62-urllib3==1.26.1360+urllib3==2.0.261 # via requestsmodified:requirements/tests.txt+4 added-6 removed
3 unmodified lines4 # To update, run:5 #6 # pip-compile-multi7 #8-attrs==22.2.08+exceptiongroup==1.1.19 # via pytest10-exceptiongroup==1.1.010+iniconfig==2.0.011 # via pytest12-iniconfig==1.1.112+packaging==23.113 # via pytest14-packaging==22.015- # via pytest14 pluggy==1.0.015 # via pytest18-pytest==7.2.016+pytest==7.3.117 # via -r requirements/tests.in18 tomli==2.0.119 # via pytestmodified:requirements/typing.txt+3 added-3 removed
3 unmodified lines4 # To update, run:5 #6 # pip-compile-multi7 #8-mypy==0.9918+mypy==1.3.09 # via -r requirements/typing.in10-mypy-extensions==0.4.310+mypy-extensions==1.0.011 # via mypy12 tomli==2.0.113 # via mypy14-typing-extensions==4.4.014+typing-extensions==4.6.215 # via mypymodified:scripts/generate_identifier_pattern.py+2 added-2 removed
27 unmodified lines28 sequential code points.29 30 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]35 36 37 def build_pattern(ranges):37 unmodified linesmodified:src/jinja2/environment.py+1 added-1 removed
701 unmodified lines702 method in.703 704 .. versionadded:: 2.5705 """706- return compile(source, filename, "exec") # type: ignore706+ return compile(source, filename, "exec")707 708 @typing.overload709 def compile( # type: ignore710 self,959 unmodified linesmodified:src/jinja2/nativetypes.py+1 added-1 removed
104 unmodified lines105 ctx = self.new_context(dict(*args, **kwargs))106 107 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 linesmodified:src/jinja2/parser.py+8 added-6 removed
309 unmodified lines310 311 # 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")322 323 self.stream.skip_if("name:" + node.name)324 return node325 716 unmodified linesmodified:src/jinja2/utils.py+1 added-1 removed
180 unmodified lines181 182 183 def pformat(obj: t.Any) -> str:184 """Format an object using :func:`pprint.pformat`."""185- from pprint import pformat # type: ignore185+ from pprint import pformat186 187 return pformat(obj)188 189 568 unmodified linesmodified:tests/test_filters.py+2 added
868 unmodified lines869 assert t1.render() == t2.render() == "foo"870 871 with pytest.raises(TemplateRuntimeError, match="No filter named 'f'"):872 t1.render(x=42)873+874+ 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 lines286 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"304 303- 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+ )309 310+ with required_block_check:311+ t.render(t="text")312+313+ with required_block_check:314+ t.render(t="block")315+316+ with required_block_check:317+ t.render(t="if")318+319 def test_required_with_scope(self, env):320 env = Environment(321 loader=DictLoader(322 {31 unmodified lines354 }355 )356 )357 tmpl = env.get_template("child")358+359 with pytest.raises(TemplateSyntaxError):360 tmpl.render(default="default1", seq=list(range(3)))361+362+ with pytest.raises(TemplateSyntaxError):363 tmpl.render(default="default2", seq=list(range(3)))364 365 366 class TestBugFix:50 unmodified linesmodified:.pre-commit-config.yaml+3 added-3 removed
1 unmodified line2 autoupdate_branch: "3.1.x"3 autoupdate_schedule: monthly4 repos: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_imports2 unmodified lines13 - 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.04 unmodified linesmodified:CHANGES.rst+9 added
7 unmodified lines8 - Use modern packaging metadata with ``pyproject.toml`` instead of ``setup.cfg``.9 :pr:`1793`10 11 12+Version 3.1.313+-------------14+15+Unreleased16+17+- Fix compiler error when checking if required blocks in parent templates are18+ empty. :pr:`1858`19+20+21 Version 3.1.222 -------------23 24 Released 2022-04-28969 unmodified linesmodified:pyproject.toml+5 added-3 removed
2 unmodified lines3 description = "A very fast and expressive template engine."4 readme = "README.rst"5 license = {text = "BSD-3-Clause"}6 maintainers = [{name = "Pallets", email = "contact@palletsprojects.com"}]7-authors = [{name = "Armin Ronacher", email = "armin.ronacher@active-4.com"}]7 classifiers = [8 "Development Status :: 5 - Production/Stable",9 "Environment :: Web Environment",10 "Intended Audience :: Developers",12 unmodified lines23 Documentation = "https://jinja.palletsprojects.com/"24 Changes = "https://jinja.palletsprojects.com/changes/"25 "Source Code" = "https://github.com/pallets/jinja/"26 "Issue Tracker" = "https://github.com/pallets/jinja/issues/"28-Twitter = "https://twitter.com/PalletsTeam"27 Chat = "https://discord.gg/pallets"28 29 [project.optional-dependencies]30 i18n = ["Babel>=2.7"]8 unmodified lines39 version = {attr = "jinja2.__version__"}40 41 [tool.pytest.ini_options]42 testpaths = ["tests"]45-filterwarnings = ["error"]43+filterwarnings = [44+ "error",45+ # change in Python 3.12 beta causes warning from inside pytest46+ "ignore:ast:DeprecationWarning",47+]48 49 [tool.coverage.run]50 branch = true51 source = ["jinja2", "tests"]19 unmodified linesmodified:README.rst-2 removed
71 unmodified lines72 - 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