Skip to content
Myr

consistent typing config

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 · parent 9b3c64d · Browse files · 8 files+29 added−27 removed
This commit

State

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

Diff stats

8 files+29 added−27 removed

  • other:+29 added−27 removed

8 files+29 added−27 removed

modified:src/jinja2/compiler.py+2 added-1 removed
1"""Compiles nodes from the parser into Python code."""2import typing as t3from collections import namedtuple4from functools import update_wrapper5from io import StringIO6from itertools import chain
1196 unmodified lines
1203 #: 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] = None12081209 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 lines
modified:src/jinja2/debug.py+1 added-1 removed
210 unmodified lines
211212elif 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 tb
43 unmodified lines
modified:src/jinja2/defaults.py+4 added-2 removed
1import typing as t23from .filters import FILTERS as DEFAULT_FILTERS # noqa: F4014from .tests import TESTS as DEFAULT_TESTS # noqa: F4015from .utils import Cycler6from .utils import generate_lorem_ipsum
6 unmodified lines
13VARIABLE_START_STRING = "{{"14VARIABLE_END_STRING = "}}"15COMMENT_START_STRING = "{#"16COMMENT_END_STRING = "#}"15LINE_STATEMENT_PREFIX = None16LINE_COMMENT_PREFIX = None17LINE_STATEMENT_PREFIX: t.Optional[str] = None18LINE_COMMENT_PREFIX: t.Optional[str] = None19TRIM_BLOCKS = False20LSTRIP_BLOCKS = False21NEWLINE_SEQUENCE = "\n"22KEEP_TRAILING_NEWLINE = False
23 unmodified lines
modified:src/jinja2/environment.py+3 added-3 removed
1 unmodified line
2options.3"""4import os5import sys6import typing as t7import weakref8from functools import partial9from functools import reduce9from typing import Any1011from markupsafe import Markup1213from . import nodes
247 unmodified lines
261 #: True if the environment is just an overlay262 overlayed = False263264 #: the environment this environment is linked to if it is an overlay265 linked_to = None265 linked_to: t.Optional["Environment"] = None266267 #: shared environments have this set to `True`. A shared environment268 #: must not be modified269 shared = False
5 unmodified lines
275 #: the context class that is used for templates. See276 #: :class:`~jinja2.runtime.Context` for more information.277 context_class = Context278279 template_class = Any279 template_class: t.Type["Template"]280281 def __init__(282 self,283 block_start_string=BLOCK_START_STRING,
1051 unmodified lines
modified:src/jinja2/runtime.py+3 added-3 removed
1"""The runtime functions and state used by compiled templates."""2import sys3import typing as t4from collections import abc5from itertools import chain6from types import MethodType7
364 unmodified lines
372373 #: Current iteration of the loop, starting at 0.374 index0 = -1375375 _length = None376 _length: t.Optional[int] = None377 _after = missing378 _current = missing379 _before = missing380 _last_changed_value = missing
381 unmodified lines
762 def __len__(self):763 return 0764765 def __iter__(self):765 if 0:766 yield None766 yield from ()767768 def __bool__(self):769 return False770
150 unmodified lines
modified:src/jinja2/utils.py+3 added-1 removed
1import json2import os3import re4import typing as t5from collections import abc6from collections import deque7from random import choice8from random import randrange9from threading import Lock10from types import CodeType11from urllib.parse import quote_from_bytes1213from markupsafe import escape14from markupsafe import Markup
1 unmodified line
16# special singleton representing missing values for the runtime17missing = type("MissingType", (), {"__repr__": lambda x: "missing"})()1819# internal code18internal_code = set()20internal_code: t.MutableSet[CodeType] = set()2122concat = "".join2324_slash_escape = "\\/" not in json.dumps("/")
724 unmodified lines
modified:setup.cfg+8 added-11 removed
82 unmodified lines
83 src/jinja2/__init__.py: F4018485[mypy]86files = src/jinja287allow_redefinition = True87python_version = 3.688disallow_subclassing_any = True89# disallow_untyped_calls = True90# disallow_untyped_defs = True91disallow_incomplete_defs = True92no_implicit_optional = True93local_partial_types = True94# no_implicit_reexport = True95strict_equality = True91strict_optional = False96warn_redundant_casts = True97warn_unused_configs = True98warn_unused_ignores = True9596[mypy-_pytest.*]97ignore_missing_imports = True9899[mypy-pytest.*]100ignore_missing_imports = True101102[mypy-requests_unixsocket.*]103ignore_missing_imports = True99warn_return_any = True100warn_unreachable = True
modified:tox.ini+5 added-5 removed
1[tox]2envlist =3 py{39,38,37,36,py3}4 style5 docs5 typing6 docs7skip_missing_interpreters = true89[testenv]10deps = -r requirements/tests.txt
3 unmodified lines
14deps = pre-commit15skip_install = true16commands = pre-commit run --all-files --show-diff-on-failure1718[testenv:docs]19deps = -r requirements/docs.txt20commands = sphinx-build -W -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html2118[testenv:typing]19deps = -r requirements/typing.txt20commands = mypy2122[testenv:docs]23deps = -r requirements/docs.txt24commands = sphinx-build -W -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html