Lindsay Young [Mon, 6 May 2019 17:10:17 +0000 (13:10 -0400)]
Create CODE_OF_CONDUCT.md
Ticket is referenced in [#Issue 1](https://github.com/pallets/meta/issues/1) in the Meta repo.
I spoke with @davidism and the decision was to use Contributor Covenant. It has easy GitHub integration and quality content.
Raul Tambre [Thu, 2 May 2019 17:23:56 +0000 (20:23 +0300)]
Fix use of 'is' operator for comparison
The 'is' operator is not meant to be used for comparisons. It currently working is an implementation detail of CPython.
CPython 3.8 has added a SyntaxWarning for this.
Kevin Brown [Mon, 6 May 2019 14:07:48 +0000 (10:07 -0400)]
Fix tox docs-html builds
These have been broken for about a month now because of the upgrade
to Sphinx 2. This upgrade happened automatically because we do not
have the version pinned.
Luckily this issue appears to only be from having Python 2 syntax in
the docs script, so making that compatible with Python 3 fixes the
error and allows the docs to pass.
Mark Amery [Sun, 25 Nov 2018 17:49:22 +0000 (17:49 +0000)]
Fix broken nl2br filter example
This example attempts to handle both Windows-style and Unix-style line endings, but does it wrong; as noted at https://stackoverflow.com/q/12521127/1709587, the regex here will match a single \r\n as if it were a double line-break, which results in all single Windows-style line-breaks getting converted into <p> breaks instead of <br> breaks as intended.
This patch fixes that by applying Alan Moore's proposed fix from https://stackoverflow.com/a/12521544/1709587 of using a negative lookahead so that a \r cannot be counted as a line break if it is followed by a \n (while still allowing the \r\n combination to count as a line break).
Jon Dufresne [Thu, 30 Aug 2018 03:58:03 +0000 (20:58 -0700)]
Trim trailing white space throughout the project
Many editors clean up trailing white space on save. By removing it all
in one go, it helps keep future diffs cleaner by avoiding spurious white
space changes on unrelated lines.
> If your project only runs on certain Python versions, setting the
> python_requires argument to the appropriate PEP 440 version specifier
> string will prevent pip from installing the project on other Python
> versions.
> python_requires
>
> A string corresponding to a version specifier (as defined in PEP 440)
> for the Python version, used to specify the Requires-Python defined in
> PEP 345.
Florian Bruhin [Wed, 27 Jun 2018 13:30:54 +0000 (15:30 +0200)]
Import abstract base classes from collections.abc
In Python 3.7, importing ABCs directly from the `collections` module shows a
warning (and in Python 3.8 it will stop working) - see
https://github.com/python/cpython/commit/c66f9f8d3909f588c251957d499599a1680e2320
This fixes various DeprecationWarnings such as those:
```
.../jinja2/utils.py:485: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
from collections import MutableMapping
.../jinja2/runtime.py:318: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
from collections import Mapping
```
Toshio Kuratomi [Mon, 29 Jan 2018 23:44:46 +0000 (15:44 -0800)]
More closely match python splatting for calls
In Python, it's legal to use splats in function calls like this:
call_function('123', *b, c=5, **d)
Prior to this change, jinja2 did not allow that. It mandated that all
splatting had to take place at the end of the call:
call_function('123', c=5, *b, **d)
This commit allows both orders.
Additionally, this commit adds tests for more things that are illegal:
namely giving a function a positional argument after using a splat to
unpack positional arguments or giving a function a named argument after
using a double splat to unpack keyword arguments.
Adrian Moennich [Tue, 22 Aug 2017 20:59:57 +0000 (22:59 +0200)]
Compile `elif` tag to `elif` instead of `else: if`
This avoids deep nesting in case of many `{% elif .. %}` blocks (which
would fail during execution) and also deep recursion (which may fail
during compilation)