Skip to content

Commit

Permalink
import Markup from markupsafe, fix flake8 import warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Jan 27, 2020
1 parent c6d864c commit 9849979
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 20 deletions.
7 changes: 4 additions & 3 deletions src/jinja2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -34,10 +37,8 @@
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"
3 changes: 2 additions & 1 deletion src/jinja2/asyncsupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
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


Expand Down
7 changes: 4 additions & 3 deletions src/jinja2/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
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
Expand All @@ -22,8 +25,6 @@
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 = {
Expand Down Expand Up @@ -712,7 +713,7 @@ def visit_Template(self, node, frame=None):
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))
Expand Down
3 changes: 0 additions & 3 deletions src/jinja2/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,3 @@
"json.dumps_kwargs": {"sort_keys": True},
"ext.i18n.trimmed": False,
}

# export all constants
__all__ = tuple(x for x in locals().keys() if x.isupper())
5 changes: 3 additions & 2 deletions src/jinja2/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
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
Expand Down Expand Up @@ -54,7 +56,6 @@
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
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/jinja2/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import re
from sys import version_info

from markupsafe import Markup

from . import nodes
from ._compat import iteritems
from ._compat import string_types
Expand All @@ -27,7 +29,6 @@
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
Expand Down
3 changes: 2 additions & 1 deletion src/jinja2/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
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,
Expand Down
10 changes: 5 additions & 5 deletions src/jinja2/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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

Expand All @@ -17,19 +17,19 @@
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",
Expand Down
2 changes: 1 addition & 1 deletion src/jinja2/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
from string import Formatter

from markupsafe import EscapeFormatter
from markupsafe import Markup

from ._compat import abc
from ._compat import PY2
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
Expand Down

0 comments on commit 9849979

Please sign in to comment.