From: David Lord Date: Mon, 27 Jan 2020 06:23:36 +0000 (-0800) Subject: import Markup from markupsafe, fix flake8 import warnings X-Git-Tag: 2.11.0~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=984997913cc2eb1a00e1b8787c3d3ada5dd359c7;p=thirdparty%2Fjinja.git import Markup from markupsafe, fix flake8 import warnings --- diff --git a/src/jinja2/__init__.py b/src/jinja2/__init__.py index 9c4c9cfc..8149c702 100644 --- a/src/jinja2/__init__.py +++ b/src/jinja2/__init__.py @@ -3,6 +3,9 @@ non-XML syntax that supports inline expressions and an optional sandboxed environment. """ +from markupsafe import escape +from markupsafe import Markup + from .bccache import BytecodeCache from .bccache import FileSystemBytecodeCache from .bccache import MemcachedBytecodeCache @@ -34,10 +37,8 @@ from .runtime import Undefined from .utils import clear_caches from .utils import contextfunction from .utils import environmentfunction -from .utils import escape from .utils import evalcontextfunction from .utils import is_undefined -from .utils import Markup from .utils import select_autoescape -__version__ = "2.11.0.dev0" +__version__ = "2.11.0rc2" diff --git a/src/jinja2/asyncsupport.py b/src/jinja2/asyncsupport.py index d97e46fc..78ba3739 100644 --- a/src/jinja2/asyncsupport.py +++ b/src/jinja2/asyncsupport.py @@ -6,11 +6,12 @@ import asyncio import inspect from functools import update_wrapper +from markupsafe import Markup + from .environment import TemplateModule from .runtime import LoopContext from .utils import concat from .utils import internalcode -from .utils import Markup from .utils import missing diff --git a/src/jinja2/compiler.py b/src/jinja2/compiler.py index 32dac88c..cbc0546d 100644 --- a/src/jinja2/compiler.py +++ b/src/jinja2/compiler.py @@ -5,6 +5,9 @@ from functools import update_wrapper from itertools import chain from keyword import iskeyword as is_python_keyword +from markupsafe import escape +from markupsafe import Markup + from . import nodes from ._compat import imap from ._compat import iteritems @@ -22,8 +25,6 @@ from .idtracking import VAR_LOAD_UNDEFINED from .nodes import EvalContext from .optimizer import Optimizer from .utils import concat -from .utils import escape -from .utils import Markup from .visitor import NodeVisitor operators = { @@ -712,7 +713,7 @@ class CodeGenerator(NodeVisitor): assert frame is None, "no root frame allowed" eval_ctx = EvalContext(self.environment, self.name) - from .runtime import __all__ as exported + from .runtime import exported self.writeline("from __future__ import %s" % ", ".join(code_features)) self.writeline("from jinja2.runtime import " + ", ".join(exported)) diff --git a/src/jinja2/defaults.py b/src/jinja2/defaults.py index b5d5f4ef..8e0e7d77 100644 --- a/src/jinja2/defaults.py +++ b/src/jinja2/defaults.py @@ -42,6 +42,3 @@ DEFAULT_POLICIES = { "json.dumps_kwargs": {"sort_keys": True}, "ext.i18n.trimmed": False, } - -# export all constants -__all__ = tuple(x for x in locals().keys() if x.isupper()) diff --git a/src/jinja2/environment.py b/src/jinja2/environment.py index 08c5e6a0..bf44b9de 100644 --- a/src/jinja2/environment.py +++ b/src/jinja2/environment.py @@ -8,6 +8,8 @@ import weakref from functools import partial from functools import reduce +from markupsafe import Markup + from . import nodes from ._compat import encode_filename from ._compat import implements_iterator @@ -54,7 +56,6 @@ from .utils import have_async_gen from .utils import import_string from .utils import internalcode from .utils import LRUCache -from .utils import Markup from .utils import missing # for direct template usage we have up to ten living environments @@ -218,7 +219,7 @@ class Environment(object): `autoescape` If set to ``True`` the XML/HTML autoescaping feature is enabled by default. For more details about autoescaping see - :class:`~jinja2.utils.Markup`. As of Jinja 2.4 this can also + :class:`~markupsafe.Markup`. As of Jinja 2.4 this can also be a callable that is passed the template name and has to return ``True`` or ``False`` depending on autoescape should be enabled by default. diff --git a/src/jinja2/ext.py b/src/jinja2/ext.py index 01aab74a..9141be4d 100644 --- a/src/jinja2/ext.py +++ b/src/jinja2/ext.py @@ -4,6 +4,8 @@ import pprint import re from sys import version_info +from markupsafe import Markup + from . import nodes from ._compat import iteritems from ._compat import string_types @@ -27,7 +29,6 @@ from .nodes import ContextReference from .runtime import concat from .utils import contextfunction from .utils import import_string -from .utils import Markup # the only real useful gettext functions for a Jinja template. Note # that ugettext must be assigned to gettext as Jinja doesn't support diff --git a/src/jinja2/nodes.py b/src/jinja2/nodes.py index f0e9e032..9f3edc05 100644 --- a/src/jinja2/nodes.py +++ b/src/jinja2/nodes.py @@ -6,11 +6,12 @@ to normalize nodes. import operator from collections import deque +from markupsafe import Markup + from ._compat import izip from ._compat import PY2 from ._compat import text_type from ._compat import with_metaclass -from .utils import Markup _binop_to_func = { "*": operator.mul, diff --git a/src/jinja2/runtime.py b/src/jinja2/runtime.py index d356b074..527d4b5e 100644 --- a/src/jinja2/runtime.py +++ b/src/jinja2/runtime.py @@ -4,7 +4,7 @@ import sys from itertools import chain from types import MethodType -from markupsafe import escape +from markupsafe import escape # noqa: F401 from markupsafe import Markup from markupsafe import soft_unicode @@ -17,19 +17,19 @@ from ._compat import PY2 from ._compat import string_types from ._compat import text_type from ._compat import with_metaclass -from .exceptions import TemplateNotFound -from .exceptions import TemplateRuntimeError +from .exceptions import TemplateNotFound # noqa: F401 +from .exceptions import TemplateRuntimeError # noqa: F401 from .exceptions import UndefinedError from .nodes import EvalContext from .utils import concat from .utils import evalcontextfunction from .utils import internalcode from .utils import missing -from .utils import Namespace +from .utils import Namespace # noqa: F401 from .utils import object_type_repr # these variables are exported to the template runtime -__all__ = [ +exported = [ "LoopContext", "TemplateReference", "Macro", diff --git a/src/jinja2/sandbox.py b/src/jinja2/sandbox.py index af4a96e6..cfd7993a 100644 --- a/src/jinja2/sandbox.py +++ b/src/jinja2/sandbox.py @@ -9,6 +9,7 @@ from collections import deque from string import Formatter from markupsafe import EscapeFormatter +from markupsafe import Markup from ._compat import abc from ._compat import PY2 @@ -16,7 +17,6 @@ from ._compat import range_type from ._compat import string_types from .environment import Environment from .exceptions import SecurityError -from .utils import Markup #: maximum number of items a range may produce MAX_RANGE = 100000