[mypy]
files = src/jinja2
-allow_redefinition = True
+python_version = 3.6
disallow_subclassing_any = True
+# disallow_untyped_calls = True
# disallow_untyped_defs = True
+disallow_incomplete_defs = True
+no_implicit_optional = True
+local_partial_types = True
+# no_implicit_reexport = True
strict_equality = True
-strict_optional = False
warn_redundant_casts = True
warn_unused_configs = True
warn_unused_ignores = True
-
-[mypy-_pytest.*]
-ignore_missing_imports = True
-
-[mypy-pytest.*]
-ignore_missing_imports = True
-
-[mypy-requests_unixsocket.*]
-ignore_missing_imports = True
+warn_return_any = True
+warn_unreachable = True
"""Compiles nodes from the parser into Python code."""
+import typing as t
from collections import namedtuple
from functools import update_wrapper
from io import StringIO
#: with one. Or if the environment has one, this is called on that
#: function's output for constants.
_default_finalize = str
- _finalize = None
+ _finalize: t.Optional[_FinalizeInfo] = None
def _make_finalize(self):
"""Build the finalize function to be used on constants and at
elif platform.python_implementation() == "PyPy":
# PyPy might have special support, and won't work with ctypes.
try:
- import tputil
+ import tputil # type: ignore
except ImportError:
# Without tproxy support, use the original traceback.
def tb_set_next(tb, tb_next):
+import typing as t
+
from .filters import FILTERS as DEFAULT_FILTERS # noqa: F401
from .tests import TESTS as DEFAULT_TESTS # noqa: F401
from .utils import Cycler
VARIABLE_END_STRING = "}}"
COMMENT_START_STRING = "{#"
COMMENT_END_STRING = "#}"
-LINE_STATEMENT_PREFIX = None
-LINE_COMMENT_PREFIX = None
+LINE_STATEMENT_PREFIX: t.Optional[str] = None
+LINE_COMMENT_PREFIX: t.Optional[str] = None
TRIM_BLOCKS = False
LSTRIP_BLOCKS = False
NEWLINE_SEQUENCE = "\n"
"""
import os
import sys
+import typing as t
import weakref
from functools import partial
from functools import reduce
-from typing import Any
from markupsafe import Markup
overlayed = False
#: the environment this environment is linked to if it is an overlay
- linked_to = None
+ linked_to: t.Optional["Environment"] = None
#: shared environments have this set to `True`. A shared environment
#: must not be modified
#: :class:`~jinja2.runtime.Context` for more information.
context_class = Context
- template_class = Any
+ template_class: t.Type["Template"]
def __init__(
self,
"""The runtime functions and state used by compiled templates."""
import sys
+import typing as t
from collections import abc
from itertools import chain
from types import MethodType
#: Current iteration of the loop, starting at 0.
index0 = -1
- _length = None
+ _length: t.Optional[int] = None
_after = missing
_current = missing
_before = missing
return 0
def __iter__(self):
- if 0:
- yield None
+ yield from ()
def __bool__(self):
return False
import json
import os
import re
+import typing as t
from collections import abc
from collections import deque
from random import choice
from random import randrange
from threading import Lock
+from types import CodeType
from urllib.parse import quote_from_bytes
from markupsafe import escape
missing = type("MissingType", (), {"__repr__": lambda x: "missing"})()
# internal code
-internal_code = set()
+internal_code: t.MutableSet[CodeType] = set()
concat = "".join
envlist =
py{39,38,37,36,py3}
style
- docs
typing
+ docs
skip_missing_interpreters = true
[testenv]
skip_install = true
commands = pre-commit run --all-files --show-diff-on-failure
-[testenv:docs]
-deps = -r requirements/docs.txt
-commands = sphinx-build -W -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html
-
[testenv:typing]
deps = -r requirements/typing.txt
commands = mypy
+
+[testenv:docs]
+deps = -r requirements/docs.txt
+commands = sphinx-build -W -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html