diff options
| author | Claude Paroz <claude@2xlibre.net> | 2016-12-29 16:27:49 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2017-01-18 20:18:46 +0100 |
| commit | 7b2f2e74adb36a4334e83130f6abc2f79d395235 (patch) | |
| tree | 313387ba6a6f1311b43cf5fb4f2576d2d6c4f805 /django/template | |
| parent | f6acd1d271122d66de8061e75ae26137ddf02658 (diff) | |
Refs #23919 -- Removed six.<various>_types usage
Thanks Tim Graham and Simon Charette for the reviews.
Diffstat (limited to 'django/template')
| -rw-r--r-- | django/template/base.py | 3 | ||||
| -rw-r--r-- | django/template/defaultfilters.py | 10 | ||||
| -rw-r--r-- | django/template/engine.py | 4 | ||||
| -rw-r--r-- | django/template/library.py | 3 | ||||
| -rw-r--r-- | django/template/loader.py | 4 | ||||
| -rw-r--r-- | django/template/response.py | 3 |
6 files changed, 11 insertions, 16 deletions
diff --git a/django/template/base.py b/django/template/base.py index aa30d2e2b3..c7c2249aa0 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -56,7 +56,6 @@ import re from django.template.context import ( # NOQA: imported for backwards compatibility BaseContext, Context, ContextPopException, RequestContext, ) -from django.utils import six from django.utils.encoding import force_str, force_text from django.utils.formats import localize from django.utils.html import conditional_escape, escape @@ -771,7 +770,7 @@ class Variable(object): self.translate = False self.message_context = None - if not isinstance(var, six.string_types): + if not isinstance(var, str): raise TypeError( "Variable must be a string or number, got %s" % type(var)) try: diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py index fc249953ea..828255b73c 100644 --- a/django/template/defaultfilters.py +++ b/django/template/defaultfilters.py @@ -6,7 +6,7 @@ from functools import wraps from operator import itemgetter from pprint import pformat -from django.utils import formats, six +from django.utils import formats from django.utils.dateformat import format, time_format from django.utils.encoding import force_text, iri_to_uri from django.utils.html import ( @@ -168,7 +168,7 @@ def floatformat(text, arg=-1): # Avoid conversion to scientific notation by accessing `sign`, `digits` # and `exponent` from `Decimal.as_tuple()` directly. sign, digits, exponent = d.quantize(exp, ROUND_HALF_UP, Context(prec=prec)).as_tuple() - digits = [six.text_type(digit) for digit in reversed(digits)] + digits = [str(digit) for digit in reversed(digits)] while len(digits) <= abs(exponent): digits.append('0') digits.insert(-exponent, '.') @@ -194,7 +194,7 @@ def linenumbers(value, autoescape=True): lines = value.split('\n') # Find the maximum width of the line count, for use with zero padding # string format command - width = six.text_type(len(six.text_type(len(lines)))) + width = str(len(str(len(lines)))) if not autoescape or isinstance(value, SafeData): for i, line in enumerate(lines): lines[i] = ("%0" + width + "d. %s") % (i + 1, line) @@ -246,7 +246,7 @@ def stringformat(value, arg): for documentation of Python string formatting. """ try: - return ("%" + six.text_type(arg)) % value + return ("%" + str(arg)) % value except (ValueError, TypeError): return "" @@ -675,7 +675,7 @@ def unordered_list(value, autoescape=True): except StopIteration: yield item, None break - if not isinstance(next_item, six.string_types): + if not isinstance(next_item, str): try: iter(next_item) except TypeError: diff --git a/django/template/engine.py b/django/template/engine.py index 154276a5b0..6d73569e02 100644 --- a/django/template/engine.py +++ b/django/template/engine.py @@ -1,5 +1,5 @@ from django.core.exceptions import ImproperlyConfigured -from django.utils import lru_cache, six +from django.utils import lru_cache from django.utils.functional import cached_property from django.utils.module_loading import import_string @@ -120,7 +120,7 @@ class Engine(object): else: args = [] - if isinstance(loader, six.string_types): + if isinstance(loader, str): loader_class = import_string(loader) return loader_class(self, *args) else: diff --git a/django/template/library.py b/django/template/library.py index 8a6c98ee09..b7e3cad532 100644 --- a/django/template/library.py +++ b/django/template/library.py @@ -1,7 +1,6 @@ import functools from importlib import import_module -from django.utils import six from django.utils.html import conditional_escape from django.utils.inspect import getargspec from django.utils.itercompat import is_iterable @@ -220,7 +219,7 @@ class InclusionNode(TagHelperNode): t = self.filename elif isinstance(getattr(self.filename, 'template', None), Template): t = self.filename.template - elif not isinstance(self.filename, six.string_types) and is_iterable(self.filename): + elif not isinstance(self.filename, str) and is_iterable(self.filename): t = context.template.engine.select_template(self.filename) else: t = context.template.engine.get_template(self.filename) diff --git a/django/template/loader.py b/django/template/loader.py index 17b278812b..fe598bc816 100644 --- a/django/template/loader.py +++ b/django/template/loader.py @@ -1,5 +1,3 @@ -from django.utils import six - from . import engines from .exceptions import TemplateDoesNotExist @@ -29,7 +27,7 @@ def select_template(template_name_list, using=None): Raises TemplateDoesNotExist if no such template exists. """ - if isinstance(template_name_list, six.string_types): + if isinstance(template_name_list, str): raise TypeError( 'select_template() takes an iterable of template names but got a ' 'string: %r. Use get_template() if you want to load a single ' diff --git a/django/template/response.py b/django/template/response.py index 95cb335ab4..e5c1fbfa66 100644 --- a/django/template/response.py +++ b/django/template/response.py @@ -1,5 +1,4 @@ from django.http import HttpResponse -from django.utils import six from .loader import get_template, select_template @@ -62,7 +61,7 @@ class SimpleTemplateResponse(HttpResponse): "Accepts a template object, path-to-template or list of paths" if isinstance(template, (list, tuple)): return select_template(template, using=self.using) - elif isinstance(template, six.string_types): + elif isinstance(template, str): return get_template(template, using=self.using) else: return template |
