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
Provenance
- Commit
d2cef39- Tree
741f445- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
9b3c64d
8 files changed+29 added−27 removed
modified: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:setup.cfg+8 added-11 removed
82 unmodified lines83 src/jinja2/__init__.py: F40184 85 [mypy]86 files = src/jinja287-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 = True91-strict_optional = False96 warn_redundant_casts = True97 warn_unused_configs = True98 warn_unused_ignores = True95-96-[mypy-_pytest.*]97-ignore_missing_imports = True98-99-[mypy-pytest.*]100-ignore_missing_imports = True101-102-[mypy-requests_unixsocket.*]103-ignore_missing_imports = True99+warn_return_any = True100+warn_unreachable = Truemodified: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