Merge branch '3.0.x'
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 · parents 7d72eb7, 5426297 · Browse files · 17 files·+46 added−44 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+46 added−44 removed
- other:+46 added−44 removed
Provenance
- Commit
896a621- Tree
dca4a04- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent 1
7d72eb7- Parent 2
5426297
17 files changed+46 added−44 removed
modified:docs/api.rst+1 added-1 removed
271 unmodified lines272 modified identifier syntax. Filters and tests may contain dots to group273 filters and tests by topic. For example it's perfectly valid to add a274 function into the filter dict and call it `to.str`. The regular275 expression for filter and test identifiers is276-``[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)*```.276+``[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)*``.277 278 279 Undefined Types280 ---------------639 unmodified linesmodified:requirements/dev.txt+16 added-15 removed
14 unmodified lines15 certifi==2021.10.816 # via requests17 cfgv==3.3.118 # via pre-commit19-charset-normalizer==2.0.719+charset-normalizer==2.0.920 # via requests21 click==8.0.322 # via pip-tools23-distlib==0.3.323+distlib==0.3.424 # via virtualenv25 docutils==0.17.126 # via sphinx27-filelock==3.3.227+filelock==3.4.028 # via29 # tox30 # virtualenv31-identify==2.3.531+identify==2.4.032 # via pre-commit33 idna==3.334 # via requests35 imagesize==1.3.03 unmodified lines39 jinja2==3.0.340 # via sphinx41 markupsafe==2.0.142 # via jinja243-mypy==0.91043+mypy==0.93044 # via -r requirements/typing.in45 mypy-extensions==0.4.346 # via mypy47 nodeenv==1.6.048 # via pre-commit49-packaging==21.249+packaging==21.350 # via51 # pallets-sphinx-themes52 # pytest53 # sphinx9 unmodified lines63 pluggy==1.0.064 # via65 # pytest66 # tox67-pre-commit==2.15.067+pre-commit==2.16.068 # via -r requirements/dev.in69 py==1.11.070 # via71 # pytest72 # tox73 pygments==2.10.074 # via sphinx75-pyparsing==2.4.775+pyparsing==3.0.676 # via packaging77 pytest==6.2.578 # via -r requirements/tests.in79 pytz==2021.35 unmodified lines85 six==1.16.086 # via87 # tox88 # virtualenv89-snowballstemmer==2.1.089+snowballstemmer==2.2.090 # via sphinx91-sphinx==4.3.091+sphinx==4.3.292 # via93 # -r requirements/docs.in94 # pallets-sphinx-themes95 # sphinx-issues15 unmodified lines111 sphinxcontrib-serializinghtml==1.1.5112 # via sphinx113 toml==0.10.2114 # via115- # mypy115 # pre-commit116 # pytest117 # tox119-tomli==1.2.2120- # via pep517118+tomli==2.0.0119+ # via120+ # mypy121+ # pep517122 tox==3.24.4123 # via -r requirements/dev.in123-typing-extensions==3.10.0.2124+typing-extensions==4.0.1125 # via mypy126 urllib3==1.26.7127 # via requests128 virtualenv==20.10.0129 # via130 # pre-commit131 # tox131-wheel==0.37.0132+wheel==0.37.1133 # via pip-tools134 135 # The following packages are considered to be unsafe in a requirements file:136 # pip1 unmodified linemodified:requirements/docs.txt+5 added-5 removed
8 unmodified lines9 babel==2.9.110 # via sphinx11 certifi==2021.10.812 # via requests13-charset-normalizer==2.0.713+charset-normalizer==2.0.914 # via requests15 docutils==0.17.116 # via sphinx17 idna==3.33 unmodified lines21 jinja2==3.0.322 # via sphinx23 markupsafe==2.0.124 # via jinja225-packaging==21.225+packaging==21.326 # via27 # pallets-sphinx-themes28 # sphinx29 pallets-sphinx-themes==2.0.230 # via -r requirements/docs.in31 pygments==2.10.032 # via sphinx33-pyparsing==2.4.733+pyparsing==3.0.634 # via packaging35 pytz==2021.336 # via babel37 requests==2.26.038 # via sphinx39-snowballstemmer==2.1.039+snowballstemmer==2.2.040 # via sphinx41-sphinx==4.3.041+sphinx==4.3.242 # via43 # -r requirements/docs.in44 # pallets-sphinx-themes45 # sphinx-issues22 unmodified linesmodified:requirements/tests.txt+2 added-2 removed
6 unmodified lines7 attrs==21.2.08 # via pytest9 iniconfig==1.1.110 # via pytest11-packaging==21.211+packaging==21.312 # via pytest13 pluggy==1.0.014 # via pytest15 py==1.11.016 # via pytest17-pyparsing==2.4.717+pyparsing==3.0.618 # via packaging19 pytest==6.2.520 # via -r requirements/tests.in21 toml==0.10.21 unmodified linemodified:requirements/typing.txt+3 added-3 removed
2 unmodified lines3 # To update, run:4 #5 # pip-compile requirements/typing.in6 #7-mypy==0.9107+mypy==0.9308 # via -r requirements/typing.in9 mypy-extensions==0.4.310 # via mypy11-toml==0.10.211+tomli==2.0.012 # via mypy13-typing-extensions==3.10.0.213+typing-extensions==4.0.114 # via mypymodified:src/jinja2/compiler.py+1 added-1 removed
216 unmodified lines217 self.soft_frame = False218 219 def copy(self) -> "Frame":220 """Create a copy of the current one."""221- rv = t.cast(Frame, object.__new__(self.__class__))221+ rv = object.__new__(self.__class__)222 rv.__dict__.update(self.__dict__)223 rv.symbols = self.symbols.copy()224 return rv225 1732 unmodified linesmodified:src/jinja2/environment.py+6 added-6 removed
937 unmodified lines938 return template939 940 @internalcode941 def _load_template(942- self, name: str, globals: t.Optional[t.Mapping[str, t.Any]]942+ self, name: str, globals: t.Optional[t.MutableMapping[str, t.Any]]943 ) -> "Template":944 if self.loader is None:945 raise TypeError("no loader for this environment specified")946 cache_key = (weakref.ref(self.loader), name)19 unmodified lines966 def get_template(967 self,968 name: t.Union[str, "Template"],969 parent: t.Optional[str] = None,970- globals: t.Optional[t.Mapping[str, t.Any]] = None,970+ globals: t.Optional[t.MutableMapping[str, t.Any]] = None,971 ) -> "Template":972 """Load a template by name with :attr:`loader` and return a973 :class:`Template`. If the template does not exist a974 :exc:`TemplateNotFound` exception is raised.26 unmodified lines1001 def select_template(1002 self,1003 names: t.Iterable[t.Union[str, "Template"]],1004 parent: t.Optional[str] = None,1005- globals: t.Optional[t.Mapping[str, t.Any]] = None,1005+ globals: t.Optional[t.MutableMapping[str, t.Any]] = None,1006 ) -> "Template":1007 """Like :meth:`get_template`, but tries loading multiple names.1008 If none of the names can be loaded a :exc:`TemplatesNotFound`1009 exception is raised.47 unmodified lines1057 template_name_or_list: t.Union[1058 str, "Template", t.List[t.Union[str, "Template"]]1059 ],1060 parent: t.Optional[str] = None,1061- globals: t.Optional[t.Mapping[str, t.Any]] = None,1061+ globals: t.Optional[t.MutableMapping[str, t.Any]] = None,1062 ) -> "Template":1063 """Use :meth:`select_template` if an iterable of template names1064 is given, or :meth:`get_template` if one name is given.1065 7 unmodified lines1073 1074 def from_string(1075 self,1076 source: t.Union[str, nodes.Template],1077- globals: t.Optional[t.Mapping[str, t.Any]] = None,1077+ globals: t.Optional[t.MutableMapping[str, t.Any]] = None,1078 template_class: t.Optional[t.Type["Template"]] = None,1079 ) -> "Template":1080 """Load a template from a source string without using1081 :attr:`loader`.10 unmodified lines1092 cls = template_class or self.template_class1093 return cls.from_code(self, self.compile(source), gs, None)1094 1095 def make_globals(1096- self, d: t.Optional[t.Mapping[str, t.Any]]1096+ self, d: t.Optional[t.MutableMapping[str, t.Any]]1097 ) -> t.MutableMapping[str, t.Any]:1098 """Make the globals map for a template. Any given template1099 globals overlay the environment :attr:`globals`.1100 555 unmodified linesmodified:src/jinja2/ext.py+1 added-1 removed
88 unmodified lines89 self.environment = environment90 91 def bind(self, environment: Environment) -> "Extension":92 """Create a copy of this extension bound to another environment."""93- rv = t.cast(Extension, object.__new__(self.__class__))93+ rv = object.__new__(self.__class__)94 rv.__dict__.update(self.__dict__)95 rv.environment = environment96 return rv97 757 unmodified linesmodified:src/jinja2/filters.py+1 added-1 removed
360 unmodified lines361 attributes, pass a comma separate list of attributes.362 363 .. sourcecode:: jinja364 365- {% for user users|sort(attribute="age,name") %}365+ {% for user in users|sort(attribute="age,name") %}366 ...367 {% endfor %}368 369 .. versionchanged:: 2.11.01402 unmodified linesmodified:src/jinja2/idtracking.py+1 added-1 removed
82 unmodified lines83 )84 return rv85 86 def copy(self) -> "Symbols":87- rv = t.cast(Symbols, object.__new__(self.__class__))87+ rv = object.__new__(self.__class__)88 rv.__dict__.update(self.__dict__)89 rv.refs = self.refs.copy()90 rv.loads = self.loads.copy()91 rv.stores = self.stores.copy()227 unmodified linesmodified:src/jinja2/lexer.py+1 added-1 removed
721 unmodified lines722 continue723 724 # tuples support more options725 if isinstance(tokens, tuple):726- groups = m.groups()726+ groups: t.Sequence[str] = m.groups()727 728 if isinstance(tokens, OptionalLStrip):729 # Rule supports lstrip. Match will look like730 # text, block type, whitespace control, type, control, ...139 unmodified linesmodified:src/jinja2/loaders.py+1 added-1 removed
601 unmodified lines602 603 if not isinstance(path, abc.Iterable) or isinstance(path, str):604 path = [path]605 606- mod.__path__ = [os.fspath(p) for p in path] # type: ignore606+ mod.__path__ = [os.fspath(p) for p in path]607 608 sys.modules[package_name] = weakref.proxy(609 mod, lambda x: sys.modules.pop(package_name, None)610 )42 unmodified linesmodified:src/jinja2/parser.py+1 added-1 removed
158 unmodified lines159 """Return a new free identifier as :class:`~jinja2.nodes.InternalName`."""160 self._last_identifier += 1161 rv = object.__new__(nodes.InternalName)162 nodes.Node.__init__(rv, f"fi{self._last_identifier}", lineno=lineno)163- return rv # type: ignore163+ return rv164 165 def parse_statement(self) -> t.Union[nodes.Node, t.List[nodes.Node]]:166 """Parse a single statement."""167 token = self.stream.current873 unmodified linesmodified:src/jinja2/sandbox.py+1 added-1 removed
407 unmodified lines408 409 class SandboxedFormatter(Formatter):410 def __init__(self, env: Environment, **kwargs: t.Any) -> None:411 self._env = env412- super().__init__(**kwargs) # type: ignore412+ super().__init__(**kwargs)413 414 def get_field(415 self, field_name: str, args: t.Sequence[t.Any], kwargs: t.Mapping[str, t.Any]416 ) -> t.Tuple[t.Any, str]:12 unmodified linesmodified:src/jinja2/visitor.py+1 added-1 removed
28 unmodified lines29 """Return the visitor function for this node or `None` if no visitor30 exists for this node. In that case the generic visit function is31 used instead.32 """33- return getattr(self, f"visit_{type(node).__name__}", None) # type: ignore33+ return getattr(self, f"visit_{type(node).__name__}", None)34 35 def visit(self, node: Node, *args: t.Any, **kwargs: t.Any) -> t.Any:36 """Visit a node."""37 f = self.get_visitor(node)55 unmodified linesmodified:.pre-commit-config.yaml+3 added-3 removed
1 ci:2 autoupdate_schedule: monthly3 repos:4 - repo: https://github.com/asottile/pyupgrade5- rev: v2.29.05+ rev: v2.29.16 hooks:7 - id: pyupgrade8 args: ["--py37-plus"]9 - repo: https://github.com/asottile/reorder_python_imports1 unmodified line11 hooks:12 - id: reorder-python-imports13 args: ["--application-directories", "src"]14 - repo: https://github.com/psf/black15- rev: 21.10b015+ rev: 21.12b016 hooks:17 - id: black18 - repo: https://github.com/PyCQA/flake819 rev: 4.0.120 hooks:21 - id: flake822 additional_dependencies: [flake8-bugbear]23 - repo: https://github.com/pre-commit/pre-commit-hooks24- rev: v4.0.124+ rev: v4.1.025 hooks:26 - id: fix-byte-order-marker27 - id: trailing-whitespace28 - id: end-of-file-fixermodified:setup.cfg+1 added
85 unmodified lines86 87 [mypy]88 files = src/jinja289 python_version = 3.790+show_error_codes = True91 disallow_subclassing_any = True92 disallow_untyped_calls = True93 disallow_untyped_defs = True94 disallow_incomplete_defs = True15 unmodified lines