Merge pull request #1361 from pallets/consistency
Before adoption: this commit came in with the history the project adopted, so no landing records it.
various cleanup for consistency between projects
authored by David Lord · committed by GitHub · parents e6577e9, e381730 · Browse files · 17 files·+87 added−54 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+87 added−54 removed
- other:+87 added−54 removed
Provenance
- Commit
ab9cd8c- Tree
446e411- Author
David Lord <davidism@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
e6577e9- Parent 2
e381730
17 files changed+87 added−54 removed
modified:.github/workflows/tests.yaml+16 added-3 removed
2 unmodified lines3456789101112131415161718192021222324252627282930313233243426273536373810 unmodified lines4950515253545556575859602 unmodified lines push: branches: - master - '*.x' paths-ignore: - 'docs/**' - '*.md' - '*.rst' pull_request: branches: - master - '*.x' paths-ignore: - 'docs/**' - '*.md' - '*.rst'jobs: tests: name: ${{ matrix.name }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: - {name: Linux, python: '3.9', os: ubuntu-latest, tox: py39} - {name: Windows, python: '3.9', os: windows-latest, tox: py39} - {name: Mac, python: '3.9', os: macos-latest, tox: py39} - {name: '3.8', python: '3.8', os: ubuntu-latest, tox: py38} - {name: '3.7', python: '3.7', os: ubuntu-latest, tox: py37} - {name: '3.6', python: '3.6', os: ubuntu-latest, tox: py36} - {name: 'PyPy', python: pypy3, os: ubuntu-latest, tox: pypy3} - {name: Docs, python: '3.9', os: ubuntu-latest, tox: docs} - {name: Typing, python: '3.9', os: ubuntu-latest, tox: typing} - {name: Windows, python: '3.9', os: windows-latest, tox: py39} - {name: Mac, python: '3.9', os: macos-latest, tox: py39} steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with:10 unmodified lines uses: actions/cache@v2 with: path: ${{ steps.pip-cache.outputs.dir }} key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('setup.py') }}|${{ hashFiles('requirements/*.txt') }} - name: cache mypy uses: actions/cache@v2 with: path: ./.mypy_cache key: mypy|${{ matrix.python }}|${{ hashFiles('setup.cfg') }} if: matrix.tox == 'typing' - run: pip install tox - run: tox -e ${{ matrix.tox }}deleted:docs/changelog.rst-4 removed
1-Changelog2-=========3-4-.. include:: ../CHANGES.rstadded:docs/changes.rst+4 added
1+Changes2+=======3+4+.. include:: ../CHANGES.rstmodified:docs/conf.py+5 added-3 removed
25 unmodified lines26 html_theme = "jinja"27 html_theme_options = {"index_sidebar_logo": False}28 html_context = {29 "project_links": [30- ProjectLink("Donate to Pallets", "https://palletsprojects.com/donate"),31- ProjectLink("Jinja Website", "https://palletsprojects.com/p/jinja/"),32- ProjectLink("PyPI releases", "https://pypi.org/project/Jinja2/"),30+ ProjectLink("Donate", "https://palletsprojects.com/donate"),31+ ProjectLink("PyPI Releases", "https://pypi.org/project/Jinja2/"),32 ProjectLink("Source Code", "https://github.com/pallets/jinja/"),33 ProjectLink("Issue Tracker", "https://github.com/pallets/jinja/issues/"),34+ ProjectLink("Website", "https://palletsprojects.com/p/jinja/"),35+ ProjectLink("Twitter", "https://twitter.com/PalletsTeam"),36+ ProjectLink("Chat", "https://discord.gg/pallets"),37 ]38 }39 html_sidebars = {40 "index": ["project.html", "localtoc.html", "searchbox.html"],12 unmodified linesmodified:docs/index.rst+2 added-1 removed
23 unmodified lines24 integration25 switching26 tricks27 faq28+ license28- changelog29+ changesadded:docs/license.rst+4 added
1+BSD-3-Clause License2+====================3+4+.. include:: ../LICENSE.rstmodified:src/jinja2/compiler.py+2 added-1 removed
1 """Compiles nodes from the parser into Python code."""2+import typing as t3 from collections import namedtuple4 from functools import update_wrapper5 from io import StringIO6 from itertools import chain1196 unmodified lines1203 #: The default finalize function if the environment isn't configured1204 #: with one. Or if the environment has one, this is called on that1205 #: function's output for constants.1206 _default_finalize = str1206- _finalize = None1207+ _finalize: t.Optional[_FinalizeInfo] = None1208 1209 def _make_finalize(self):1210 """Build the finalize function to be used on constants and at1211 runtime. Cached so it's only created once for all output nodes.553 unmodified linesmodified:src/jinja2/debug.py+1 added-1 removed
210 unmodified lines211 212 elif platform.python_implementation() == "PyPy":213 # PyPy might have special support, and won't work with ctypes.214 try:215- import tputil215+ import tputil # type: ignore216 except ImportError:217 # Without tproxy support, use the original traceback.218 def tb_set_next(tb, tb_next):219 return tb43 unmodified linesmodified:src/jinja2/defaults.py+4 added-2 removed
1+import typing as t2+3 from .filters import FILTERS as DEFAULT_FILTERS # noqa: F4014 from .tests import TESTS as DEFAULT_TESTS # noqa: F4015 from .utils import Cycler6 from .utils import generate_lorem_ipsum6 unmodified lines13 VARIABLE_START_STRING = "{{"14 VARIABLE_END_STRING = "}}"15 COMMENT_START_STRING = "{#"16 COMMENT_END_STRING = "#}"15-LINE_STATEMENT_PREFIX = None16-LINE_COMMENT_PREFIX = None17+LINE_STATEMENT_PREFIX: t.Optional[str] = None18+LINE_COMMENT_PREFIX: t.Optional[str] = None19 TRIM_BLOCKS = False20 LSTRIP_BLOCKS = False21 NEWLINE_SEQUENCE = "\n"22 KEEP_TRAILING_NEWLINE = False23 unmodified linesmodified:src/jinja2/environment.py+3 added-3 removed
1 unmodified line2 options.3 """4 import os5 import sys6+import typing as t7 import weakref8 from functools import partial9 from functools import reduce9-from typing import Any10 11 from markupsafe import Markup12 13 from . import nodes247 unmodified lines261 #: True if the environment is just an overlay262 overlayed = False263 264 #: the environment this environment is linked to if it is an overlay265- linked_to = None265+ linked_to: t.Optional["Environment"] = None266 267 #: shared environments have this set to `True`. A shared environment268 #: must not be modified269 shared = False5 unmodified lines275 #: the context class that is used for templates. See276 #: :class:`~jinja2.runtime.Context` for more information.277 context_class = Context278 279- template_class = Any279+ template_class: t.Type["Template"]280 281 def __init__(282 self,283 block_start_string=BLOCK_START_STRING,1051 unmodified linesmodified:src/jinja2/runtime.py+3 added-3 removed
1 """The runtime functions and state used by compiled templates."""2 import sys3+import typing as t4 from collections import abc5 from itertools import chain6 from types import MethodType7 364 unmodified lines372 373 #: Current iteration of the loop, starting at 0.374 index0 = -1375 375- _length = None376+ _length: t.Optional[int] = None377 _after = missing378 _current = missing379 _before = missing380 _last_changed_value = missing381 unmodified lines762 def __len__(self):763 return 0764 765 def __iter__(self):765- if 0:766- yield None766+ yield from ()767 768 def __bool__(self):769 return False770 150 unmodified linesmodified:src/jinja2/utils.py+3 added-1 removed
1 import json2 import os3 import re4+import typing as t5 from collections import abc6 from collections import deque7 from random import choice8 from random import randrange9 from threading import Lock10+from types import CodeType11 from urllib.parse import quote_from_bytes12 13 from markupsafe import escape14 from markupsafe import Markup1 unmodified line16 # special singleton representing missing values for the runtime17 missing = type("MissingType", (), {"__repr__": lambda x: "missing"})()18 19 # internal code18-internal_code = set()20+internal_code: t.MutableSet[CodeType] = set()21 22 concat = "".join23 24 _slash_escape = "\\/" not in json.dumps("/")724 unmodified linesmodified:.readthedocs.yaml+1 added
4 unmodified lines5 - method: pip6 path: .7 sphinx:8 builder: dirhtml9+ fail_on_warning: truemodified:README.rst+18 added-6 removed
52 unmodified lines53 </ul>54 {% endblock %}55 56 57+Donate58+------59+60+The Pallets organization develops and supports Jinja and other popular61+packages. In order to grow the community of contributors and users, and62+allow the maintainers to devote more time to the projects, `please63+donate today`_.64+65+.. _please donate today: https://palletsprojects.com/donate66+67+68 Links69 -----70 60-- Website: https://palletsprojects.com/p/jinja/71 - Documentation: https://jinja.palletsprojects.com/62-- Releases: https://pypi.org/project/Jinja2/63-- Code: https://github.com/pallets/jinja64-- Issue tracker: https://github.com/pallets/jinja/issues65-- Test status: https://dev.azure.com/pallets/jinja/_build66-- Official chat: https://discord.gg/t6rrQZH72+- 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/PalletsTeam78+- Chat: https://discord.gg/palletsmodified:setup.cfg+16 added-15 removed
1 [metadata]2 name = Jinja23-# Version needs regex in setup.py.4-url = https://palletsprojects.com/p/jinja3+version = attr: jinja2.__version__4+url = https://palletsprojects.com/p/jinja/5 project_urls =6+ Donate = https://palletsprojects.com/donate7 Documentation = https://jinja.palletsprojects.com/7- Code = https://github.com/pallets/jinja8- Issue tracker = https://github.com/pallets/jinja/issues8+ Changes = https://jinja.palletsprojects.com/changes/9+ Source Code = https://github.com/pallets/jinja/10+ Issue Tracker = https://github.com/pallets/jinja/issues/11+ Twitter = https://twitter.com/PalletsTeam12+ Chat = https://discord.gg/pallets13 license = BSD-3-Clause14 license_files = LICENSE.rst15 author = Armin Ronacher16 author_email = armin.ronacher@active-4.com66 unmodified lines83 src/jinja2/__init__.py: F40184 85 [mypy]86 files = src/jinja283-allow_redefinition = True87+python_version = 3.688 disallow_subclassing_any = True89+# disallow_untyped_calls = True90 # disallow_untyped_defs = True91+disallow_incomplete_defs = True92+no_implicit_optional = True93+local_partial_types = True94+# no_implicit_reexport = True95 strict_equality = True87-strict_optional = False96 warn_redundant_casts = True97 warn_unused_configs = True98 warn_unused_ignores = True91-92-[mypy-_pytest.*]93-ignore_missing_imports = True94-95-[mypy-pytest.*]96-ignore_missing_imports = True97-98-[mypy-requests_unixsocket.*]99-ignore_missing_imports = True99+warn_return_any = True100+warn_unreachable = Truemodified:setup.py-6 removed
1-import re2-1 from setuptools import setup2 5-with open("src/jinja2/__init__.py", encoding="utf8") as f:6- version = re.search(r'__version__ = "(.*?)"', f.read(), re.M).group(1)7-3 # Metadata goes in setup.cfg. These are here for GitHub's dependency graph.4 setup(5 name="Jinja2",11- version=version,6 install_requires=["MarkupSafe>=1.1"],7 extras_require={"i18n": ["Babel>=2.1"]},8 )modified:tox.ini+5 added-5 removed
1 [tox]2 envlist =3 py{39,38,37,36,py3}4 style5- docs5 typing6+ docs7 skip_missing_interpreters = true8 9 [testenv]10 deps = -r requirements/tests.txt3 unmodified lines14 deps = pre-commit15 skip_install = true16 commands = pre-commit run --all-files --show-diff-on-failure17 18-[testenv:docs]19-deps = -r requirements/docs.txt20-commands = sphinx-build -W -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html21-18 [testenv:typing]19 deps = -r requirements/typing.txt20 commands = mypy21+22+[testenv:docs]23+deps = -r requirements/docs.txt24+commands = sphinx-build -W -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html