Merge branch '3.0.x'

This commit is contained in:
David Lord 2021-12-26 07:48:45 -07:00
commit 896a62135b
No known key found for this signature in database
GPG Key ID: 7A1C87E3F5BC42A8
17 changed files with 46 additions and 44 deletions

View File

@ -2,7 +2,7 @@ ci:
autoupdate_schedule: monthly
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.29.0
rev: v2.29.1
hooks:
- id: pyupgrade
args: ["--py37-plus"]
@ -12,7 +12,7 @@ repos:
- id: reorder-python-imports
args: ["--application-directories", "src"]
- repo: https://github.com/psf/black
rev: 21.10b0
rev: 21.12b0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
@ -21,7 +21,7 @@ repos:
- id: flake8
additional_dependencies: [flake8-bugbear]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.1.0
hooks:
- id: fix-byte-order-marker
- id: trailing-whitespace

View File

@ -273,7 +273,7 @@ modified identifier syntax. Filters and tests may contain dots to group
filters and tests by topic. For example it's perfectly valid to add a
function into the filter dict and call it `to.str`. The regular
expression for filter and test identifiers is
``[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)*```.
``[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)*``.
Undefined Types

View File

@ -16,19 +16,19 @@ certifi==2021.10.8
# via requests
cfgv==3.3.1
# via pre-commit
charset-normalizer==2.0.7
charset-normalizer==2.0.9
# via requests
click==8.0.3
# via pip-tools
distlib==0.3.3
distlib==0.3.4
# via virtualenv
docutils==0.17.1
# via sphinx
filelock==3.3.2
filelock==3.4.0
# via
# tox
# virtualenv
identify==2.3.5
identify==2.4.0
# via pre-commit
idna==3.3
# via requests
@ -40,13 +40,13 @@ jinja2==3.0.3
# via sphinx
markupsafe==2.0.1
# via jinja2
mypy==0.910
mypy==0.930
# via -r requirements/typing.in
mypy-extensions==0.4.3
# via mypy
nodeenv==1.6.0
# via pre-commit
packaging==21.2
packaging==21.3
# via
# pallets-sphinx-themes
# pytest
@ -64,7 +64,7 @@ pluggy==1.0.0
# via
# pytest
# tox
pre-commit==2.15.0
pre-commit==2.16.0
# via -r requirements/dev.in
py==1.11.0
# via
@ -72,7 +72,7 @@ py==1.11.0
# tox
pygments==2.10.0
# via sphinx
pyparsing==2.4.7
pyparsing==3.0.6
# via packaging
pytest==6.2.5
# via -r requirements/tests.in
@ -86,9 +86,9 @@ six==1.16.0
# via
# tox
# virtualenv
snowballstemmer==2.1.0
snowballstemmer==2.2.0
# via sphinx
sphinx==4.3.0
sphinx==4.3.2
# via
# -r requirements/docs.in
# pallets-sphinx-themes
@ -112,15 +112,16 @@ sphinxcontrib-serializinghtml==1.1.5
# via sphinx
toml==0.10.2
# via
# mypy
# pre-commit
# pytest
# tox
tomli==1.2.2
# via pep517
tomli==2.0.0
# via
# mypy
# pep517
tox==3.24.4
# via -r requirements/dev.in
typing-extensions==3.10.0.2
typing-extensions==4.0.1
# via mypy
urllib3==1.26.7
# via requests
@ -128,7 +129,7 @@ virtualenv==20.10.0
# via
# pre-commit
# tox
wheel==0.37.0
wheel==0.37.1
# via pip-tools
# The following packages are considered to be unsafe in a requirements file:

View File

@ -10,7 +10,7 @@ babel==2.9.1
# via sphinx
certifi==2021.10.8
# via requests
charset-normalizer==2.0.7
charset-normalizer==2.0.9
# via requests
docutils==0.17.1
# via sphinx
@ -22,7 +22,7 @@ jinja2==3.0.3
# via sphinx
markupsafe==2.0.1
# via jinja2
packaging==21.2
packaging==21.3
# via
# pallets-sphinx-themes
# sphinx
@ -30,15 +30,15 @@ pallets-sphinx-themes==2.0.2
# via -r requirements/docs.in
pygments==2.10.0
# via sphinx
pyparsing==2.4.7
pyparsing==3.0.6
# via packaging
pytz==2021.3
# via babel
requests==2.26.0
# via sphinx
snowballstemmer==2.1.0
snowballstemmer==2.2.0
# via sphinx
sphinx==4.3.0
sphinx==4.3.2
# via
# -r requirements/docs.in
# pallets-sphinx-themes

View File

@ -8,13 +8,13 @@ attrs==21.2.0
# via pytest
iniconfig==1.1.1
# via pytest
packaging==21.2
packaging==21.3
# via pytest
pluggy==1.0.0
# via pytest
py==1.11.0
# via pytest
pyparsing==2.4.7
pyparsing==3.0.6
# via packaging
pytest==6.2.5
# via -r requirements/tests.in

View File

@ -4,11 +4,11 @@
#
# pip-compile requirements/typing.in
#
mypy==0.910
mypy==0.930
# via -r requirements/typing.in
mypy-extensions==0.4.3
# via mypy
toml==0.10.2
tomli==2.0.0
# via mypy
typing-extensions==3.10.0.2
typing-extensions==4.0.1
# via mypy

View File

@ -87,6 +87,7 @@ per-file-ignores =
[mypy]
files = src/jinja2
python_version = 3.7
show_error_codes = True
disallow_subclassing_any = True
disallow_untyped_calls = True
disallow_untyped_defs = True

View File

@ -218,7 +218,7 @@ class Frame:
def copy(self) -> "Frame":
"""Create a copy of the current one."""
rv = t.cast(Frame, object.__new__(self.__class__))
rv = object.__new__(self.__class__)
rv.__dict__.update(self.__dict__)
rv.symbols = self.symbols.copy()
return rv

View File

@ -939,7 +939,7 @@ class Environment:
@internalcode
def _load_template(
self, name: str, globals: t.Optional[t.Mapping[str, t.Any]]
self, name: str, globals: t.Optional[t.MutableMapping[str, t.Any]]
) -> "Template":
if self.loader is None:
raise TypeError("no loader for this environment specified")
@ -967,7 +967,7 @@ class Environment:
self,
name: t.Union[str, "Template"],
parent: t.Optional[str] = None,
globals: t.Optional[t.Mapping[str, t.Any]] = None,
globals: t.Optional[t.MutableMapping[str, t.Any]] = None,
) -> "Template":
"""Load a template by name with :attr:`loader` and return a
:class:`Template`. If the template does not exist a
@ -1002,7 +1002,7 @@ class Environment:
self,
names: t.Iterable[t.Union[str, "Template"]],
parent: t.Optional[str] = None,
globals: t.Optional[t.Mapping[str, t.Any]] = None,
globals: t.Optional[t.MutableMapping[str, t.Any]] = None,
) -> "Template":
"""Like :meth:`get_template`, but tries loading multiple names.
If none of the names can be loaded a :exc:`TemplatesNotFound`
@ -1058,7 +1058,7 @@ class Environment:
str, "Template", t.List[t.Union[str, "Template"]]
],
parent: t.Optional[str] = None,
globals: t.Optional[t.Mapping[str, t.Any]] = None,
globals: t.Optional[t.MutableMapping[str, t.Any]] = None,
) -> "Template":
"""Use :meth:`select_template` if an iterable of template names
is given, or :meth:`get_template` if one name is given.
@ -1074,7 +1074,7 @@ class Environment:
def from_string(
self,
source: t.Union[str, nodes.Template],
globals: t.Optional[t.Mapping[str, t.Any]] = None,
globals: t.Optional[t.MutableMapping[str, t.Any]] = None,
template_class: t.Optional[t.Type["Template"]] = None,
) -> "Template":
"""Load a template from a source string without using
@ -1093,7 +1093,7 @@ class Environment:
return cls.from_code(self, self.compile(source), gs, None)
def make_globals(
self, d: t.Optional[t.Mapping[str, t.Any]]
self, d: t.Optional[t.MutableMapping[str, t.Any]]
) -> t.MutableMapping[str, t.Any]:
"""Make the globals map for a template. Any given template
globals overlay the environment :attr:`globals`.

View File

@ -90,7 +90,7 @@ class Extension:
def bind(self, environment: Environment) -> "Extension":
"""Create a copy of this extension bound to another environment."""
rv = t.cast(Extension, object.__new__(self.__class__))
rv = object.__new__(self.__class__)
rv.__dict__.update(self.__dict__)
rv.environment = environment
return rv

View File

@ -362,7 +362,7 @@ def do_sort(
.. sourcecode:: jinja
{% for user users|sort(attribute="age,name") %}
{% for user in users|sort(attribute="age,name") %}
...
{% endfor %}

View File

@ -84,7 +84,7 @@ class Symbols:
return rv
def copy(self) -> "Symbols":
rv = t.cast(Symbols, object.__new__(self.__class__))
rv = object.__new__(self.__class__)
rv.__dict__.update(self.__dict__)
rv.refs = self.refs.copy()
rv.loads = self.loads.copy()

View File

@ -723,7 +723,7 @@ class Lexer:
# tuples support more options
if isinstance(tokens, tuple):
groups = m.groups()
groups: t.Sequence[str] = m.groups()
if isinstance(tokens, OptionalLStrip):
# Rule supports lstrip. Match will look like

View File

@ -603,7 +603,7 @@ class ModuleLoader(BaseLoader):
if not isinstance(path, abc.Iterable) or isinstance(path, str):
path = [path]
mod.__path__ = [os.fspath(p) for p in path] # type: ignore
mod.__path__ = [os.fspath(p) for p in path]
sys.modules[package_name] = weakref.proxy(
mod, lambda x: sys.modules.pop(package_name, None)

View File

@ -160,7 +160,7 @@ class Parser:
self._last_identifier += 1
rv = object.__new__(nodes.InternalName)
nodes.Node.__init__(rv, f"fi{self._last_identifier}", lineno=lineno)
return rv # type: ignore
return rv
def parse_statement(self) -> t.Union[nodes.Node, t.List[nodes.Node]]:
"""Parse a single statement."""

View File

@ -409,7 +409,7 @@ class ImmutableSandboxedEnvironment(SandboxedEnvironment):
class SandboxedFormatter(Formatter):
def __init__(self, env: Environment, **kwargs: t.Any) -> None:
self._env = env
super().__init__(**kwargs) # type: ignore
super().__init__(**kwargs)
def get_field(
self, field_name: str, args: t.Sequence[t.Any], kwargs: t.Mapping[str, t.Any]

View File

@ -30,7 +30,7 @@ class NodeVisitor:
exists for this node. In that case the generic visit function is
used instead.
"""
return getattr(self, f"visit_{type(node).__name__}", None) # type: ignore
return getattr(self, f"visit_{type(node).__name__}", None)
def visit(self, node: Node, *args: t.Any, **kwargs: t.Any) -> t.Any:
"""Visit a node."""