summaryrefslogtreecommitdiff
path: root/django/contrib
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2016-12-29 16:27:49 +0100
committerClaude Paroz <claude@2xlibre.net>2017-01-18 20:18:46 +0100
commit7b2f2e74adb36a4334e83130f6abc2f79d395235 (patch)
tree313387ba6a6f1311b43cf5fb4f2576d2d6c4f805 /django/contrib
parentf6acd1d271122d66de8061e75ae26137ddf02658 (diff)
Refs #23919 -- Removed six.<various>_types usage
Thanks Tim Graham and Simon Charette for the reviews.
Diffstat (limited to 'django/contrib')
-rw-r--r--django/contrib/admin/helpers.py5
-rw-r--r--django/contrib/admin/options.py10
-rw-r--r--django/contrib/admin/utils.py8
-rw-r--r--django/contrib/admin/widgets.py3
-rw-r--r--django/contrib/auth/decorators.py3
-rw-r--r--django/contrib/auth/mixins.py3
-rw-r--r--django/contrib/auth/models.py9
-rw-r--r--django/contrib/auth/password_validation.py5
-rw-r--r--django/contrib/auth/tokens.py6
-rw-r--r--django/contrib/gis/admin/widgets.py4
-rw-r--r--django/contrib/gis/db/backends/base/models.py3
-rw-r--r--django/contrib/gis/db/backends/oracle/operations.py3
-rw-r--r--django/contrib/gis/db/backends/postgis/operations.py5
-rw-r--r--django/contrib/gis/db/backends/spatialite/introspection.py5
-rw-r--r--django/contrib/gis/db/models/fields.py3
-rw-r--r--django/contrib/gis/db/models/functions.py13
-rw-r--r--django/contrib/gis/db/models/lookups.py3
-rw-r--r--django/contrib/gis/db/models/proxy.py5
-rw-r--r--django/contrib/gis/forms/widgets.py4
-rw-r--r--django/contrib/gis/gdal/datasource.py5
-rw-r--r--django/contrib/gis/gdal/driver.py3
-rw-r--r--django/contrib/gis/gdal/feature.py3
-rw-r--r--django/contrib/gis/gdal/geometries.py10
-rw-r--r--django/contrib/gis/gdal/geomtype.py5
-rw-r--r--django/contrib/gis/gdal/layer.py3
-rw-r--r--django/contrib/gis/gdal/prototypes/errcheck.py7
-rw-r--r--django/contrib/gis/gdal/raster/source.py7
-rw-r--r--django/contrib/gis/gdal/srs.py7
-rw-r--r--django/contrib/gis/geoip2/base.py5
-rw-r--r--django/contrib/gis/geos/factory.py2
-rw-r--r--django/contrib/gis/geos/geometry.py8
-rw-r--r--django/contrib/gis/geos/mutable_list.py7
-rw-r--r--django/contrib/gis/geos/point.py5
-rw-r--r--django/contrib/gis/geos/polygon.py3
-rw-r--r--django/contrib/gis/geos/prototypes/io.py4
-rw-r--r--django/contrib/gis/measure.py4
-rw-r--r--django/contrib/gis/utils/layermapping.py8
-rw-r--r--django/contrib/gis/utils/ogrinspect.py5
-rw-r--r--django/contrib/messages/storage/session.py3
-rw-r--r--django/contrib/postgres/fields/array.py3
-rw-r--r--django/contrib/postgres/fields/hstore.py5
-rw-r--r--django/contrib/postgres/fields/ranges.py3
-rw-r--r--django/contrib/postgres/forms/array.py3
-rw-r--r--django/contrib/postgres/forms/hstore.py3
-rw-r--r--django/contrib/postgres/forms/jsonb.py7
45 files changed, 96 insertions, 132 deletions
diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py
index ea56840445..628788b3fa 100644
--- a/django/contrib/admin/helpers.py
+++ b/django/contrib/admin/helpers.py
@@ -10,7 +10,6 @@ from django.core.exceptions import ObjectDoesNotExist
from django.db.models.fields.related import ManyToManyRel
from django.forms.utils import flatatt
from django.template.defaultfilters import capfirst, linebreaksbr
-from django.utils import six
from django.utils.encoding import force_text
from django.utils.html import conditional_escape, format_html
from django.utils.safestring import mark_safe
@@ -99,7 +98,7 @@ class Fieldset(object):
class Fieldline(object):
def __init__(self, form, field, readonly_fields=None, model_admin=None):
self.form = form # A django.forms.Form instance
- if not hasattr(field, "__iter__") or isinstance(field, six.text_type):
+ if not hasattr(field, "__iter__") or isinstance(field, str):
self.fields = [field]
else:
self.fields = field
@@ -217,7 +216,7 @@ class AdminReadonlyField(object):
result_repr = linebreaksbr(force_text(value))
else:
if isinstance(f.remote_field, ManyToManyRel) and value is not None:
- result_repr = ", ".join(map(six.text_type, value.all()))
+ result_repr = ", ".join(map(str, value.all()))
else:
result_repr = display_for_field(value, f, self.empty_value_display)
result_repr = linebreaksbr(result_repr)
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index bb871513d7..eaa9916056 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -1068,8 +1068,8 @@ class ModelAdmin(BaseModelAdmin):
attr = obj._meta.pk.attname
value = obj.serializable_value(attr)
popup_response_data = json.dumps({
- 'value': six.text_type(value),
- 'obj': six.text_type(obj),
+ 'value': str(value),
+ 'obj': str(obj),
})
return TemplateResponse(request, self.popup_response_template or [
'admin/%s/%s/popup_response.html' % (opts.app_label, opts.model_name),
@@ -1129,9 +1129,9 @@ class ModelAdmin(BaseModelAdmin):
new_value = obj.serializable_value(attr)
popup_response_data = json.dumps({
'action': 'change',
- 'value': six.text_type(value),
- 'obj': six.text_type(obj),
- 'new_value': six.text_type(new_value),
+ 'value': str(value),
+ 'obj': str(obj),
+ 'new_value': str(new_value),
})
return TemplateResponse(request, self.popup_response_template or [
'admin/%s/%s/popup_response.html' % (opts.app_label, opts.model_name),
diff --git a/django/contrib/admin/utils.py b/django/contrib/admin/utils.py
index cf17381548..297796254d 100644
--- a/django/contrib/admin/utils.py
+++ b/django/contrib/admin/utils.py
@@ -10,7 +10,7 @@ from django.db.models.deletion import Collector
from django.db.models.sql.constants import QUERY_TERMS
from django.forms.utils import pretty_name
from django.urls import NoReverseMatch, reverse
-from django.utils import formats, six, timezone
+from django.utils import formats, timezone
from django.utils.encoding import force_str, force_text, smart_text
from django.utils.html import format_html
from django.utils.text import capfirst
@@ -68,7 +68,7 @@ def quote(s):
Similar to urllib.quote, except that the quoting is slightly different so
that it doesn't get automatically unquoted by the Web browser.
"""
- if not isinstance(s, six.string_types):
+ if not isinstance(s, str):
return s
res = list(s)
for i in range(len(res)):
@@ -342,7 +342,7 @@ def label_for_field(name, model, model_admin=None, return_attr=False):
except FieldDoesNotExist:
if name == "__unicode__":
label = force_text(model._meta.verbose_name)
- attr = six.text_type
+ attr = str
elif name == "__str__":
label = force_str(model._meta.verbose_name)
attr = bytes
@@ -430,7 +430,7 @@ def display_for_value(value, empty_value_display, boolean=False):
return formats.localize(timezone.template_localtime(value))
elif isinstance(value, (datetime.date, datetime.time)):
return formats.localize(value)
- elif isinstance(value, six.integer_types + (decimal.Decimal, float)):
+ elif isinstance(value, (int, decimal.Decimal, float)):
return formats.number_format(value)
elif isinstance(value, (list, tuple)):
return ', '.join(force_text(v) for v in value)
diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
index 9f93ae3a42..9f6fb412b2 100644
--- a/django/contrib/admin/widgets.py
+++ b/django/contrib/admin/widgets.py
@@ -7,7 +7,6 @@ from django import forms
from django.db.models.deletion import CASCADE
from django.urls import reverse
from django.urls.exceptions import NoReverseMatch
-from django.utils import six
from django.utils.encoding import force_text
from django.utils.html import smart_urlquote
from django.utils.safestring import mark_safe
@@ -111,7 +110,7 @@ def url_params_from_lookup_dict(lookups):
elif isinstance(v, bool):
v = ('0', '1')[v]
else:
- v = six.text_type(v)
+ v = str(v)
items.append((k, v))
params.update(dict(items))
return params
diff --git a/django/contrib/auth/decorators.py b/django/contrib/auth/decorators.py
index 9c44108c89..f6e4c1d5b2 100644
--- a/django/contrib/auth/decorators.py
+++ b/django/contrib/auth/decorators.py
@@ -4,7 +4,6 @@ from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.core.exceptions import PermissionDenied
from django.shortcuts import resolve_url
-from django.utils import six
from django.utils.decorators import available_attrs
from django.utils.six.moves.urllib.parse import urlparse
@@ -60,7 +59,7 @@ def permission_required(perm, login_url=None, raise_exception=False):
is raised.
"""
def check_perms(user):
- if isinstance(perm, six.string_types):
+ if isinstance(perm, str):
perms = (perm, )
else:
perms = perm
diff --git a/django/contrib/auth/mixins.py b/django/contrib/auth/mixins.py
index 4a7759435b..c52b573658 100644
--- a/django/contrib/auth/mixins.py
+++ b/django/contrib/auth/mixins.py
@@ -2,7 +2,6 @@ from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.auth.views import redirect_to_login
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
-from django.utils import six
from django.utils.encoding import force_text
@@ -73,7 +72,7 @@ class PermissionRequiredMixin(AccessMixin):
'{0} is missing the permission_required attribute. Define {0}.permission_required, or override '
'{0}.get_permission_required().'.format(self.__class__.__name__)
)
- if isinstance(self.permission_required, six.string_types):
+ if isinstance(self.permission_required, str):
perms = (self.permission_required, )
else:
perms = self.permission_required
diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py
index 7155bd1199..0fc2ab41da 100644
--- a/django/contrib/auth/models.py
+++ b/django/contrib/auth/models.py
@@ -6,7 +6,7 @@ from django.core.exceptions import PermissionDenied
from django.core.mail import send_mail
from django.db import models
from django.db.models.manager import EmptyManager
-from django.utils import six, timezone
+from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from .validators import UnicodeUsernameValidator
@@ -75,9 +75,10 @@ class Permission(models.Model):
def __str__(self):
return "%s | %s | %s" % (
- six.text_type(self.content_type.app_label),
- six.text_type(self.content_type),
- six.text_type(self.name))
+ self.content_type.app_label,
+ self.content_type,
+ self.name,
+ )
def natural_key(self):
return (self.codename,) + self.content_type.natural_key()
diff --git a/django/contrib/auth/password_validation.py b/django/contrib/auth/password_validation.py
index d802a5f5fd..1cf32e0219 100644
--- a/django/contrib/auth/password_validation.py
+++ b/django/contrib/auth/password_validation.py
@@ -13,7 +13,6 @@ from django.utils.encoding import force_text
from django.utils.functional import lazy
from django.utils.html import format_html
from django.utils.module_loading import import_string
-from django.utils.six import string_types, text_type
from django.utils.translation import ugettext as _, ungettext
@@ -88,7 +87,7 @@ def _password_validators_help_text_html(password_validators=None):
return '<ul>%s</ul>' % ''.join(help_items) if help_items else ''
-password_validators_help_text_html = lazy(_password_validators_help_text_html, text_type)
+password_validators_help_text_html = lazy(_password_validators_help_text_html, str)
class MinimumLengthValidator(object):
@@ -141,7 +140,7 @@ class UserAttributeSimilarityValidator(object):
for attribute_name in self.user_attributes:
value = getattr(user, attribute_name, None)
- if not value or not isinstance(value, string_types):
+ if not value or not isinstance(value, str):
continue
value_parts = re.split(r'\W+', value) + [value]
for value_part in value_parts:
diff --git a/django/contrib/auth/tokens.py b/django/contrib/auth/tokens.py
index 6cf694cebb..18ff42f192 100644
--- a/django/contrib/auth/tokens.py
+++ b/django/contrib/auth/tokens.py
@@ -1,7 +1,6 @@
from datetime import date
from django.conf import settings
-from django.utils import six
from django.utils.crypto import constant_time_compare, salted_hmac
from django.utils.http import base36_to_int, int_to_base36
@@ -68,10 +67,7 @@ class PasswordResetTokenGenerator(object):
def _make_hash_value(self, user, timestamp):
# Ensure results are consistent across DB backends
login_timestamp = '' if user.last_login is None else user.last_login.replace(microsecond=0, tzinfo=None)
- return (
- six.text_type(user.pk) + user.password +
- six.text_type(login_timestamp) + six.text_type(timestamp)
- )
+ return str(user.pk) + user.password + str(login_timestamp) + str(timestamp)
def _num_days(self, dt):
return (dt - date(2001, 1, 1)).days
diff --git a/django/contrib/gis/admin/widgets.py b/django/contrib/gis/admin/widgets.py
index 014b3ad818..b76e860324 100644
--- a/django/contrib/gis/admin/widgets.py
+++ b/django/contrib/gis/admin/widgets.py
@@ -3,7 +3,7 @@ import logging
from django.contrib.gis.gdal import GDALException
from django.contrib.gis.geos import GEOSException, GEOSGeometry
from django.forms.widgets import Textarea
-from django.utils import six, translation
+from django.utils import translation
# Creating a template context that contains Django settings
# values needed by admin map templates.
@@ -30,7 +30,7 @@ class OpenLayersWidget(Textarea):
# If a string reaches here (via a validation error on another
# field) then just reconstruct the Geometry.
- if value and isinstance(value, six.string_types):
+ if value and isinstance(value, str):
try:
value = GEOSGeometry(value)
except (GEOSException, ValueError) as err:
diff --git a/django/contrib/gis/db/backends/base/models.py b/django/contrib/gis/db/backends/base/models.py
index 8c8bdc6346..8388a27f25 100644
--- a/django/contrib/gis/db/backends/base/models.py
+++ b/django/contrib/gis/db/backends/base/models.py
@@ -1,5 +1,4 @@
from django.contrib.gis import gdal
-from django.utils import six
class SpatialRefSysMixin(object):
@@ -134,4 +133,4 @@ class SpatialRefSysMixin(object):
"""
Returns the string representation, a 'pretty' OGC WKT.
"""
- return six.text_type(self.srs)
+ return str(self.srs)
diff --git a/django/contrib/gis/db/backends/oracle/operations.py b/django/contrib/gis/db/backends/oracle/operations.py
index 013ffa74f6..a431b916be 100644
--- a/django/contrib/gis/db/backends/oracle/operations.py
+++ b/django/contrib/gis/db/backends/oracle/operations.py
@@ -17,7 +17,6 @@ from django.contrib.gis.db.models import aggregates
from django.contrib.gis.geometry.backend import Geometry
from django.contrib.gis.measure import Distance
from django.db.backends.oracle.operations import DatabaseOperations
-from django.utils import six
from django.utils.functional import cached_property
DEFAULT_TOLERANCE = '0.05'
@@ -45,7 +44,7 @@ class SDORelate(SpatialOperator):
def check_relate_argument(self, arg):
masks = 'TOUCH|OVERLAPBDYDISJOINT|OVERLAPBDYINTERSECT|EQUAL|INSIDE|COVEREDBY|CONTAINS|COVERS|ANYINTERACT|ON'
mask_regex = re.compile(r'^(%s)(\+(%s))*$' % (masks, masks), re.I)
- if not isinstance(arg, six.string_types) or not mask_regex.match(arg):
+ if not isinstance(arg, str) or not mask_regex.match(arg):
raise ValueError('Invalid SDO_RELATE mask: "%s"' % arg)
def as_sql(self, connection, lookup, template_params, sql_params):
diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py
index ae0821694a..678c420c23 100644
--- a/django/contrib/gis/db/backends/postgis/operations.py
+++ b/django/contrib/gis/db/backends/postgis/operations.py
@@ -9,7 +9,6 @@ from django.contrib.gis.measure import Distance
from django.core.exceptions import ImproperlyConfigured
from django.db.backends.postgresql.operations import DatabaseOperations
from django.db.utils import ProgrammingError
-from django.utils import six
from django.utils.functional import cached_property
from .adapter import PostGISAdapter
@@ -337,7 +336,7 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
# Get the srid for this object
if value is None:
value_srid = None
- elif f.geom_type == 'RASTER' and isinstance(value, six.string_types):
+ elif f.geom_type == 'RASTER' and isinstance(value, str):
value_srid = get_pgraster_srid(value)
else:
value_srid = value.srid
@@ -346,7 +345,7 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
# is not equal to the field srid.
if value_srid is None or value_srid == f.srid:
placeholder = '%s'
- elif f.geom_type == 'RASTER' and isinstance(value, six.string_types):
+ elif f.geom_type == 'RASTER' and isinstance(value, str):
placeholder = '%s((%%s)::raster, %s)' % (self.transform, f.srid)
else:
placeholder = '%s(%%s, %s)' % (self.transform, f.srid)
diff --git a/django/contrib/gis/db/backends/spatialite/introspection.py b/django/contrib/gis/db/backends/spatialite/introspection.py
index 6c3ed1864c..467e3a44f7 100644
--- a/django/contrib/gis/db/backends/spatialite/introspection.py
+++ b/django/contrib/gis/db/backends/spatialite/introspection.py
@@ -2,7 +2,6 @@ from django.contrib.gis.gdal import OGRGeomType
from django.db.backends.sqlite3.introspection import (
DatabaseIntrospection, FlexibleFieldLookupDict,
)
-from django.utils import six
class GeoFlexibleFieldLookupDict(FlexibleFieldLookupDict):
@@ -41,7 +40,7 @@ class SpatiaLiteIntrospection(DatabaseIntrospection):
# OGRGeomType does not require GDAL and makes it easy to convert
# from OGC geom type name to Django field.
ogr_type = row[2]
- if isinstance(ogr_type, six.integer_types) and ogr_type > 1000:
+ if isinstance(ogr_type, int) and ogr_type > 1000:
# SpatiaLite versions >= 4 use the new SFSQL 1.2 offsets
# 1000 (Z), 2000 (M), and 3000 (ZM) to indicate the presence of
# higher dimensional coordinates (M not yet supported by Django).
@@ -54,7 +53,7 @@ class SpatiaLiteIntrospection(DatabaseIntrospection):
field_params = {}
if srid != 4326:
field_params['srid'] = srid
- if (isinstance(dim, six.string_types) and 'Z' in dim) or dim == 3:
+ if (isinstance(dim, str) and 'Z' in dim) or dim == 3:
field_params['dim'] = 3
finally:
cursor.close()
diff --git a/django/contrib/gis/db/models/fields.py b/django/contrib/gis/db/models/fields.py
index 215a17b6b5..6435dc4077 100644
--- a/django/contrib/gis/db/models/fields.py
+++ b/django/contrib/gis/db/models/fields.py
@@ -10,7 +10,6 @@ from django.contrib.gis.geometry.backend import Geometry, GeometryException
from django.core.exceptions import ImproperlyConfigured
from django.db.models.expressions import Expression
from django.db.models.fields import Field
-from django.utils import six
from django.utils.translation import ugettext_lazy as _
# Local cache of the spatial_ref_sys table, which holds SRID data for each
@@ -226,7 +225,7 @@ class BaseSpatialField(Field):
pass
else:
# Check if input is a candidate for conversion to raster or geometry.
- is_candidate = isinstance(obj, (bytes, six.string_types)) or hasattr(obj, '__geo_interface__')
+ is_candidate = isinstance(obj, (bytes, str)) or hasattr(obj, '__geo_interface__')
# Try to convert the input to raster.
raster = self.get_raster_prep_value(obj, is_candidate)
diff --git a/django/contrib/gis/db/models/functions.py b/django/contrib/gis/db/models/functions.py
index 8a4d54aac1..77628afa34 100644
--- a/django/contrib/gis/db/models/functions.py
+++ b/django/contrib/gis/db/models/functions.py
@@ -9,9 +9,8 @@ from django.contrib.gis.measure import (
from django.core.exceptions import FieldError
from django.db.models import BooleanField, FloatField, IntegerField, TextField
from django.db.models.expressions import Func, Value
-from django.utils import six
-NUMERIC_TYPES = six.integer_types + (float, Decimal)
+NUMERIC_TYPES = (int, float, Decimal)
class GeoFunc(Func):
@@ -161,7 +160,7 @@ class AsGeoJSON(GeoFunc):
def __init__(self, expression, bbox=False, crs=False, precision=8, **extra):
expressions = [expression]
if precision is not None:
- expressions.append(self._handle_param(precision, 'precision', six.integer_types))
+ expressions.append(self._handle_param(precision, 'precision', int))
options = 0
if crs and bbox:
options = 3
@@ -181,7 +180,7 @@ class AsGML(GeoFunc):
def __init__(self, expression, version=2, precision=8, **extra):
expressions = [version, expression]
if precision is not None:
- expressions.append(self._handle_param(precision, 'precision', six.integer_types))
+ expressions.append(self._handle_param(precision, 'precision', int))
super(AsGML, self).__init__(*expressions, **extra)
def as_oracle(self, compiler, connection, **extra_context):
@@ -208,7 +207,7 @@ class AsSVG(GeoFunc):
expressions = [
expression,
relative,
- self._handle_param(precision, 'precision', six.integer_types),
+ self._handle_param(precision, 'precision', int),
]
super(AsSVG, self).__init__(*expressions, **extra)
@@ -311,7 +310,7 @@ class GeoHash(GeoFunc):
def __init__(self, expression, precision=None, **extra):
expressions = [expression]
if precision is not None:
- expressions.append(self._handle_param(precision, 'precision', six.integer_types))
+ expressions.append(self._handle_param(precision, 'precision', int))
super(GeoHash, self).__init__(*expressions, **extra)
@@ -458,7 +457,7 @@ class Transform(GeoFunc):
def __init__(self, expression, srid, **extra):
expressions = [
expression,
- self._handle_param(srid, 'srid', six.integer_types),
+ self._handle_param(srid, 'srid', int),
]
if 'output_field' not in extra:
extra['output_field'] = GeometryField(srid=srid)
diff --git a/django/contrib/gis/db/models/lookups.py b/django/contrib/gis/db/models/lookups.py
index b707a9cbff..3b2d4b8497 100644
--- a/django/contrib/gis/db/models/lookups.py
+++ b/django/contrib/gis/db/models/lookups.py
@@ -5,7 +5,6 @@ from django.db.models.constants import LOOKUP_SEP
from django.db.models.expressions import Col, Expression
from django.db.models.lookups import Lookup, Transform
from django.db.models.sql.query import Query
-from django.utils import six
gis_lookups = {}
@@ -389,7 +388,7 @@ class RelateLookup(GISLookup):
backend_op.check_relate_argument(value[1])
else:
pattern = value[1]
- if not isinstance(pattern, six.string_types) or not self.pattern_regex.match(pattern):
+ if not isinstance(pattern, str) or not self.pattern_regex.match(pattern):
raise ValueError('Invalid intersection matrix pattern "%s".' % pattern)
return super(RelateLookup, self).get_db_prep_lookup(value, connection)
diff --git a/django/contrib/gis/db/models/proxy.py b/django/contrib/gis/db/models/proxy.py
index 340e76f4bf..86221daca7 100644
--- a/django/contrib/gis/db/models/proxy.py
+++ b/django/contrib/gis/db/models/proxy.py
@@ -6,7 +6,6 @@ objects corresponding to geographic model fields.
Thanks to Robert Coup for providing this functionality (see #4322).
"""
from django.db.models.query_utils import DeferredAttribute
-from django.utils import six
class SpatialProxy(DeferredAttribute):
@@ -58,7 +57,7 @@ class SpatialProxy(DeferredAttribute):
# The geographic type of the field.
gtype = self._field.geom_type
- if gtype == 'RASTER' and (value is None or isinstance(value, six.string_types + (dict, self._klass))):
+ if gtype == 'RASTER' and (value is None or isinstance(value, (str, dict, self._klass))):
# For raster fields, assure input is None or a string, dict, or
# raster instance.
pass
@@ -68,7 +67,7 @@ class SpatialProxy(DeferredAttribute):
if value.srid is None:
# Assigning the field SRID if the geometry has no SRID.
value.srid = self._field.srid
- elif value is None or isinstance(value, six.string_types + (six.memoryview,)):
+ elif value is None or isinstance(value, (str, memoryview)):
# Set geometries with None, WKT, HEX, or WKB
pass
else:
diff --git a/django/contrib/gis/forms/widgets.py b/django/contrib/gis/forms/widgets.py
index 2e7e530cc2..0c1fc23c81 100644
--- a/django/contrib/gis/forms/widgets.py
+++ b/django/contrib/gis/forms/widgets.py
@@ -4,7 +4,7 @@ from django.conf import settings
from django.contrib.gis import gdal
from django.contrib.gis.geos import GEOSException, GEOSGeometry
from django.forms.widgets import Widget
-from django.utils import six, translation
+from django.utils import translation
logger = logging.getLogger('django.contrib.gis')
@@ -43,7 +43,7 @@ class BaseGeometryWidget(Widget):
def get_context(self, name, value, attrs=None):
# If a string reaches here (via a validation error on another
# field) then just reconstruct the Geometry.
- if value and isinstance(value, six.string_types):
+ if value and isinstance(value, str):
value = self.deserialize(value)
if value:
diff --git a/django/contrib/gis/gdal/datasource.py b/django/contrib/gis/gdal/datasource.py
index 4588a1731a..1ff2326a63 100644
--- a/django/contrib/gis/gdal/datasource.py
+++ b/django/contrib/gis/gdal/datasource.py
@@ -40,7 +40,6 @@ from django.contrib.gis.gdal.driver import Driver
from django.contrib.gis.gdal.error import GDALException, OGRIndexError
from django.contrib.gis.gdal.layer import Layer
from django.contrib.gis.gdal.prototypes import ds as capi
-from django.utils import six
from django.utils.encoding import force_bytes, force_text
from django.utils.six.moves import range
@@ -64,7 +63,7 @@ class DataSource(GDALBase):
Driver.ensure_registered()
- if isinstance(ds_input, six.string_types):
+ if isinstance(ds_input, str):
# The data source driver is a void pointer.
ds_driver = Driver.ptr_type()
try:
@@ -93,7 +92,7 @@ class DataSource(GDALBase):
def __getitem__(self, index):
"Allows use of the index [] operator to get a layer at the index."
- if isinstance(index, six.string_types):
+ if isinstance(index, str):
layer = capi.get_layer_by_name(self.ptr, force_bytes(index))
if not layer:
raise OGRIndexError('invalid OGR Layer name given: "%s"' % index)
diff --git a/django/contrib/gis/gdal/driver.py b/django/contrib/gis/gdal/driver.py
index 7ed4587073..20ebaeff20 100644
--- a/django/contrib/gis/gdal/driver.py
+++ b/django/contrib/gis/gdal/driver.py
@@ -3,7 +3,6 @@ from ctypes import c_void_p
from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.error import GDALException
from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
-from django.utils import six
from django.utils.encoding import force_bytes, force_text
@@ -36,7 +35,7 @@ class Driver(GDALBase):
"""
Initializes an GDAL/OGR driver on either a string or integer input.
"""
- if isinstance(dr_input, six.string_types):
+ if isinstance(dr_input, str):
# If a string name of the driver was passed in
self.ensure_registered()
diff --git a/django/contrib/gis/gdal/feature.py b/django/contrib/gis/gdal/feature.py
index 2335df733b..8975b9c076 100644
--- a/django/contrib/gis/gdal/feature.py
+++ b/django/contrib/gis/gdal/feature.py
@@ -3,7 +3,6 @@ from django.contrib.gis.gdal.error import GDALException, OGRIndexError
from django.contrib.gis.gdal.field import Field
from django.contrib.gis.gdal.geometries import OGRGeometry, OGRGeomType
from django.contrib.gis.gdal.prototypes import ds as capi, geom as geom_api
-from django.utils import six
from django.utils.encoding import force_bytes, force_text
from django.utils.six.moves import range
@@ -35,7 +34,7 @@ class Feature(GDALBase):
is not the field's _value_ -- use the `get` method instead to
retrieve the value (e.g. an integer) instead of a Field instance.
"""
- if isinstance(index, six.string_types):
+ if isinstance(index, str):
i = self.index(index)
else:
if index < 0 or index > self.num_fields:
diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py
index 08d0a23767..28ef2907ac 100644
--- a/django/contrib/gis/gdal/geometries.py
+++ b/django/contrib/gis/gdal/geometries.py
@@ -67,7 +67,7 @@ class OGRGeometry(GDALBase):
def __init__(self, geom_input, srs=None):
"Initializes Geometry on either WKT or an OGR pointer as input."
- str_instance = isinstance(geom_input, six.string_types)
+ str_instance = isinstance(geom_input, str)
# If HEX, unpack input to a binary buffer.
if str_instance and hex_regex.match(geom_input):
@@ -276,7 +276,7 @@ class OGRGeometry(GDALBase):
# (decremented) when this geometry's destructor is called.
if isinstance(srs, SpatialReference):
srs_ptr = srs.ptr
- elif isinstance(srs, six.integer_types + six.string_types):
+ elif isinstance(srs, (int, str)):
sr = SpatialReference(srs)
srs_ptr = sr.ptr
elif srs is None:
@@ -295,7 +295,7 @@ class OGRGeometry(GDALBase):
return None
def _set_srid(self, srid):
- if isinstance(srid, six.integer_types) or srid is None:
+ if isinstance(srid, int) or srid is None:
self.srs = srid
else:
raise TypeError('SRID must be set with an integer.')
@@ -403,7 +403,7 @@ class OGRGeometry(GDALBase):
capi.geom_transform(self.ptr, coord_trans.ptr)
elif isinstance(coord_trans, SpatialReference):
capi.geom_transform_to(self.ptr, coord_trans.ptr)
- elif isinstance(coord_trans, six.integer_types + six.string_types):
+ elif isinstance(coord_trans, (int, str)):
sr = SpatialReference(coord_trans)
capi.geom_transform_to(self.ptr, sr.ptr)
else:
@@ -675,7 +675,7 @@ class GeometryCollection(OGRGeometry):
capi.add_geom(self.ptr, g.ptr)
else:
capi.add_geom(self.ptr, geom.ptr)
- elif isinstance(geom, six.string_types):
+ elif isinstance(geom, str):
tmp = OGRGeometry(geom)
capi.add_geom(self.ptr, tmp.ptr)
else:
diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py
index 0ed7e66343..79c3356f5e 100644
--- a/django/contrib/gis/gdal/geomtype.py
+++ b/django/contrib/gis/gdal/geomtype.py
@@ -1,5 +1,4 @@
from django.contrib.gis.gdal.error import GDALException
-from django.utils import six
class OGRGeomType(object):
@@ -34,7 +33,7 @@ class OGRGeomType(object):
"Figures out the correct OGR Type based upon the input."
if isinstance(type_input, OGRGeomType):
num = type_input.num
- elif isinstance(type_input, six.string_types):
+ elif isinstance(type_input, str):
type_input = type_input.lower()
if type_input == 'geometry':
type_input = 'unknown'
@@ -62,7 +61,7 @@ class OGRGeomType(object):
"""
if isinstance(other, OGRGeomType):
return self.num == other.num
- elif isinstance(other, six.string_types):
+ elif isinstance(other, str):
return self.name.lower() == other.lower()
elif isinstance(other, int):
return self.num == other
diff --git a/django/contrib/gis/gdal/layer.py b/django/contrib/gis/gdal/layer.py
index e7e13f9468..fbbede81b0 100644
--- a/django/contrib/gis/gdal/layer.py
+++ b/django/contrib/gis/gdal/layer.py
@@ -13,7 +13,6 @@ from django.contrib.gis.gdal.prototypes import (
ds as capi, geom as geom_api, srs as srs_api,
)
from django.contrib.gis.gdal.srs import SpatialReference
-from django.utils import six
from django.utils.encoding import force_bytes, force_text
from django.utils.six.moves import range
@@ -42,7 +41,7 @@ class Layer(GDALBase):
def __getitem__(self, index):
"Gets the Feature at the specified index."
- if isinstance(index, six.integer_types):
+ if isinstance(index, int):
# An integer index was given -- we cannot do a check based on the
# number of features because the beginning and ending feature IDs
# are not guaranteed to be 0 and len(layer)-1, respectively.
diff --git a/django/contrib/gis/gdal/prototypes/errcheck.py b/django/contrib/gis/gdal/prototypes/errcheck.py
index a721087654..9b83095131 100644
--- a/django/contrib/gis/gdal/prototypes/errcheck.py
+++ b/django/contrib/gis/gdal/prototypes/errcheck.py
@@ -8,7 +8,6 @@ from django.contrib.gis.gdal.error import (
GDALException, SRSException, check_err,
)
from django.contrib.gis.gdal.libgdal import lgdal
-from django.utils import six
# Helper routines for retrieving pointers and/or values from
@@ -79,7 +78,7 @@ def check_geom(result, func, cargs):
"Checks a function that returns a geometry."
# OGR_G_Clone may return an integer, even though the
# restype is set to c_void_p
- if isinstance(result, six.integer_types):
+ if isinstance(result, int):
result = c_void_p(result)
if not result:
raise GDALException('Invalid geometry pointer returned from "%s".' % func.__name__)
@@ -95,7 +94,7 @@ def check_geom_offset(result, func, cargs, offset=-1):
# ### Spatial Reference error-checking routines ###
def check_srs(result, func, cargs):
- if isinstance(result, six.integer_types):
+ if isinstance(result, int):
result = c_void_p(result)
if not result:
raise SRSException('Invalid spatial reference pointer returned from "%s".' % func.__name__)
@@ -121,7 +120,7 @@ def check_errcode(result, func, cargs, cpl=False):
def check_pointer(result, func, cargs):
"Makes sure the result pointer is valid."
- if isinstance(result, six.integer_types):
+ if isinstance(result, int):
result = c_void_p(result)
if result:
return result
diff --git a/django/contrib/gis/gdal/raster/source.py b/django/contrib/gis/gdal/raster/source.py
index f3a565ddc8..3cafe738a4 100644
--- a/django/contrib/gis/gdal/raster/source.py
+++ b/django/contrib/gis/gdal/raster/source.py
@@ -10,7 +10,6 @@ from django.contrib.gis.gdal.raster.band import BandList
from django.contrib.gis.gdal.raster.const import GDAL_RESAMPLE_ALGORITHMS
from django.contrib.gis.gdal.srs import SpatialReference, SRSException
from django.contrib.gis.geometry.regex import json_regex
-from django.utils import six
from django.utils.encoding import force_bytes, force_text
from django.utils.functional import cached_property
@@ -62,11 +61,11 @@ class GDALRaster(GDALBase):
# Preprocess json inputs. This converts json strings to dictionaries,
# which are parsed below the same way as direct dictionary inputs.
- if isinstance(ds_input, six.string_types) and json_regex.match(ds_input):
+ if isinstance(ds_input, str) and json_regex.match(ds_input):
ds_input = json.loads(ds_input)
# If input is a valid file path, try setting file as source.
- if isinstance(ds_input, six.string_types):
+ if isinstance(ds_input, str):
if not os.path.exists(ds_input):
raise GDALException('Unable to read raster source input "{}"'.format(ds_input))
try:
@@ -215,7 +214,7 @@ class GDALRaster(GDALBase):
"""
if isinstance(value, SpatialReference):
srs = value
- elif isinstance(value, six.integer_types + six.string_types):
+ elif isinstance(value, (int, str)):
srs = SpatialReference(value)
else:
raise ValueError('Could not create a SpatialReference from input.')
diff --git a/django/contrib/gis/gdal/srs.py b/django/contrib/gis/gdal/srs.py
index 635cdc2b5a..9dc9080de7 100644
--- a/django/contrib/gis/gdal/srs.py
+++ b/django/contrib/gis/gdal/srs.py
@@ -31,7 +31,6 @@ from ctypes import byref, c_char_p, c_int
from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.error import SRSException
from django.contrib.gis.gdal.prototypes import srs as capi
-from django.utils import six
from django.utils.encoding import force_bytes, force_text
@@ -55,7 +54,7 @@ class SpatialReference(GDALBase):
self.ptr = capi.new_srs(c_char_p(b''))
self.import_wkt(srs_input)
return
- elif isinstance(srs_input, six.string_types):
+ elif isinstance(srs_input, str):
try:
# If SRID is a string, e.g., '4326', then make acceptable
# as user input.
@@ -63,7 +62,7 @@ class SpatialReference(GDALBase):
srs_input = 'EPSG:%d' % srid
except ValueError:
pass
- elif isinstance(srs_input, six.integer_types):
+ elif isinstance(srs_input, int):
# EPSG integer code was input.
srs_type = 'epsg'
elif isinstance(srs_input, self.ptr_type):
@@ -130,7 +129,7 @@ class SpatialReference(GDALBase):
The attribute value for the given target node (e.g. 'PROJCS'). The index
keyword specifies an index of the child node to return.
"""
- if not isinstance(target, six.string_types) or not isinstance(index, int):
+ if not isinstance(target, str) or not isinstance(index, int):
raise TypeError
return capi.get_attr_value(self.ptr, force_bytes(target), index)
diff --git a/django/contrib/gis/geoip2/base.py b/django/contrib/gis/geoip2/base.py
index 44164f1d71..1d1e2e00dc 100644
--- a/django/contrib/gis/geoip2/base.py
+++ b/django/contrib/gis/geoip2/base.py
@@ -5,7 +5,6 @@ import geoip2.database
from django.conf import settings
from django.core.validators import ipv4_re
-from django.utils import six
from django.utils.ipv6 import is_valid_ipv6_address
from .resources import City, Country
@@ -78,7 +77,7 @@ class GeoIP2(object):
path = GEOIP_SETTINGS['GEOIP_PATH']
if not path:
raise GeoIP2Exception('GeoIP path must be provided via parameter or the GEOIP_PATH setting.')
- if not isinstance(path, six.string_types):
+ if not isinstance(path, str):
raise TypeError('Invalid path type: %s' % type(path).__name__)
if os.path.isdir(path):
@@ -146,7 +145,7 @@ class GeoIP2(object):
def _check_query(self, query, country=False, city=False, city_or_country=False):
"Helper routine for checking the query and database availability."
# Making sure a string was passed in for the query.
- if not isinstance(query, six.string_types):
+ if not isinstance(query, str):
raise TypeError('GeoIP query must be a string, not type %s' % type(query).__name__)
# Extra checks for the existence of country and city databases.
diff --git a/django/contrib/gis/geos/factory.py b/django/contrib/gis/geos/factory.py
index eb06da2c00..42cd10c756 100644
--- a/django/contrib/gis/geos/factory.py
+++ b/django/contrib/gis/geos/factory.py
@@ -8,7 +8,7 @@ def fromfile(file_h):
WKT, or HEX.
"""
# If given a file name, get a real handle.
- if isinstance(file_h, six.string_types):
+ if isinstance(file_h, str):
with open(file_h, 'rb') as file_h:
buf = file_h.read()
else:
diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py
index deadbfaaf2..f7bdf8937f 100644
--- a/django/contrib/gis/geos/geometry.py
+++ b/django/contrib/gis/geos/geometry.py
@@ -49,7 +49,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
"""
if isinstance(geo_input, bytes):
geo_input = force_text(geo_input)
- if isinstance(geo_input, six.string_types):
+ if isinstance(geo_input, str):
wkt_m = wkt_regex.match(geo_input)
if wkt_m:
# Handling WKT input.
@@ -63,7 +63,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
# Handling GeoJSON input.
g = wkb_r().read(gdal.OGRGeometry(geo_input).wkb)
else:
- raise ValueError('String or unicode input unrecognized as WKT EWKT, and HEXEWKB.')
+ raise ValueError('String input unrecognized as WKT EWKT, and HEXEWKB.')
elif isinstance(geo_input, GEOM_PTR):
# When the input is a pointer to a geometry (GEOM_PTR).
g = geo_input
@@ -169,7 +169,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
Equivalence testing, a Geometry may be compared with another Geometry
or an EWKT representation.
"""
- if isinstance(other, six.string_types):
+ if isinstance(other, str):
if other.startswith('SRID=0;'):
return self.ewkt == other[7:] # Test only WKT part of other
return self.ewkt == other
@@ -348,7 +348,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
Returns true if the elements in the DE-9IM intersection matrix for the
two Geometries match the elements in pattern.
"""
- if not isinstance(pattern, six.string_types) or len(pattern) > 9:
+ if not isinstance(pattern, str) or len(pattern) > 9:
raise GEOSException('invalid intersection matrix pattern')
return capi.geos_relatepattern(self.ptr, other.ptr, force_bytes(pattern))
diff --git a/django/contrib/gis/geos/mutable_list.py b/django/contrib/gis/geos/mutable_list.py
index 8a613600c0..8896ebc518 100644
--- a/django/contrib/gis/geos/mutable_list.py
+++ b/django/contrib/gis/geos/mutable_list.py
@@ -10,7 +10,6 @@ Author: Aryeh Leib Taurog.
"""
from functools import total_ordering
-from django.utils import six
from django.utils.six.moves import range
@@ -82,12 +81,12 @@ class ListMixin(object):
def __delitem__(self, index):
"Delete the item(s) at the specified index/slice."
- if not isinstance(index, six.integer_types + (slice,)):
+ if not isinstance(index, (int, slice)):
raise TypeError("%s is not a legal index" % index)
# calculate new length and dimensions
origLen = len(self)
- if isinstance(index, six.integer_types):
+ if isinstance(index, int):
index = self._checkindex(index)
indexRange = [index]
else:
@@ -195,7 +194,7 @@ class ListMixin(object):
def insert(self, index, val):
"Standard list insert method"
- if not isinstance(index, six.integer_types):
+ if not isinstance(index, int):
raise TypeError("%s is not a legal index" % index)
self[index:index] = [val]
diff --git a/django/contrib/gis/geos/point.py b/django/contrib/gis/geos/point.py
index ec95cf1f63..fadf5eb414 100644
--- a/django/contrib/gis/geos/point.py
+++ b/django/contrib/gis/geos/point.py
@@ -4,7 +4,6 @@ from django.contrib.gis import gdal
from django.contrib.gis.geos import prototypes as capi
from django.contrib.gis.geos.error import GEOSException
from django.contrib.gis.geos.geometry import GEOSGeometry
-from django.utils import six
from django.utils.six.moves import range
@@ -27,9 +26,9 @@ class Point(GEOSGeometry):
elif isinstance(x, (tuple, list)):
# Here a tuple or list was passed in under the `x` parameter.
coords = x
- elif isinstance(x, six.integer_types + (float,)) and isinstance(y, six.integer_types + (float,)):
+ elif isinstance(x, (float, int)) and isinstance(y, (float, int)):
# Here X, Y, and (optionally) Z were passed in individually, as parameters.
- if isinstance(z, six.integer_types + (float,)):
+ if isinstance(z, (float, int)):
coords = [x, y, z]
else:
coords = [x, y]
diff --git a/django/contrib/gis/geos/polygon.py b/django/contrib/gis/geos/polygon.py
index 434e27b4d9..0b4de0d3c3 100644
--- a/django/contrib/gis/geos/polygon.py
+++ b/django/contrib/gis/geos/polygon.py
@@ -4,7 +4,6 @@ from django.contrib.gis.geos import prototypes as capi
from django.contrib.gis.geos.geometry import GEOSGeometry
from django.contrib.gis.geos.libgeos import GEOM_PTR, get_pointer_arr
from django.contrib.gis.geos.linestring import LinearRing
-from django.utils import six
from django.utils.six.moves import range
@@ -63,7 +62,7 @@ class Polygon(GEOSGeometry):
"Constructs a Polygon from a bounding box (4-tuple)."
x0, y0, x1, y1 = bbox
for z in bbox:
- if not isinstance(z, six.integer_types + (float,)):
+ if not isinstance(z, (float, int)):
return GEOSGeometry('POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' %
(x0, y0, x0, y1, x1, y1, x1, y0, x0, y0))
return Polygon(((x0, y0), (x0, y1), (x1, y1), (x1, y0), (x0, y0)))
diff --git a/django/contrib/gis/geos/prototypes/io.py b/django/contrib/gis/geos/prototypes/io.py
index c932a1a15f..1cc0ccb8f3 100644
--- a/django/contrib/gis/geos/prototypes/io.py
+++ b/django/contrib/gis/geos/prototypes/io.py
@@ -135,7 +135,7 @@ class _WKTReader(IOBase):
destructor = wkt_reader_destroy
def read(self, wkt):
- if not isinstance(wkt, (bytes, six.string_types)):
+ if not isinstance(wkt, (bytes, str)):
raise TypeError
return wkt_reader_read(self.ptr, force_bytes(wkt))
@@ -150,7 +150,7 @@ class _WKBReader(IOBase):
if isinstance(wkb, six.memoryview):
wkb_s = bytes(wkb)
return wkb_reader_read(self.ptr, wkb_s, len(wkb_s))
- elif isinstance(wkb, (bytes, six.string_types)):
+ elif isinstance(wkb, (bytes, str)):
return wkb_reader_read_hex(self.ptr, wkb, len(wkb))
else:
raise TypeError
diff --git a/django/contrib/gis/measure.py b/django/contrib/gis/measure.py
index 71bc5ff83b..8691d009a6 100644
--- a/django/contrib/gis/measure.py
+++ b/django/contrib/gis/measure.py
@@ -42,7 +42,7 @@ from django.utils import six
__all__ = ['A', 'Area', 'D', 'Distance']
-NUMERIC_TYPES = six.integer_types + (float, Decimal)
+NUMERIC_TYPES = (int, float, Decimal)
AREA_PREFIX = "sq_"
@@ -60,7 +60,7 @@ class MeasureBase(object):
def __init__(self, default_unit=None, **kwargs):
value, self._default_unit = self.default_units(kwargs)
setattr(self, self.STANDARD_UNIT, value)
- if default_unit and isinstance(default_unit, six.string_types):
+ if default_unit and isinstance(default_unit, str):
self._default_unit = default_unit
def _get_standard(self):
diff --git a/django/contrib/gis/utils/layermapping.py b/django/contrib/gis/utils/layermapping.py
index 22d7dd2579..a10e9bbeb8 100644
--- a/django/contrib/gis/utils/layermapping.py
+++ b/django/contrib/gis/utils/layermapping.py
@@ -89,7 +89,7 @@ class LayerMapping(object):
argument usage.
"""
# Getting the DataSource and the associated Layer.
- if isinstance(data, six.string_types):
+ if isinstance(data, str):
self.ds = DataSource(data, encoding=encoding)
else:
self.ds = data
@@ -266,7 +266,7 @@ class LayerMapping(object):
sr = source_srs
elif isinstance(source_srs, self.spatial_backend.spatial_ref_sys()):
sr = source_srs.srs
- elif isinstance(source_srs, (int, six.string_types)):
+ elif isinstance(source_srs, (int, str)):
sr = SpatialReference(source_srs)
else:
# Otherwise just pulling the SpatialReference from the layer
@@ -284,7 +284,7 @@ class LayerMapping(object):
for attr in unique:
if attr not in self.mapping:
raise ValueError
- elif isinstance(unique, six.string_types):
+ elif isinstance(unique, str):
# Only a single field passed in.
if unique not in self.mapping:
raise ValueError
@@ -331,7 +331,7 @@ class LayerMapping(object):
will construct and return the uniqueness keyword arguments -- a subset
of the feature kwargs.
"""
- if isinstance(self.unique, six.string_types):
+ if isinstance(self.unique, str):
return {self.unique: kwargs[self.unique]}
else:
return {fld: kwargs[fld] for fld in self.unique}
diff --git a/django/contrib/gis/utils/ogrinspect.py b/django/contrib/gis/utils/ogrinspect.py
index 71e4c64878..c10364491d 100644
--- a/django/contrib/gis/utils/ogrinspect.py
+++ b/django/contrib/gis/utils/ogrinspect.py
@@ -8,7 +8,6 @@ from django.contrib.gis.gdal.field import (
OFTDate, OFTDateTime, OFTInteger, OFTInteger64, OFTReal, OFTString,
OFTTime,
)
-from django.utils import six
from django.utils.six.moves import zip
@@ -26,7 +25,7 @@ def mapping(data_source, geom_name='geom', layer_key=0, multi_geom=False):
`multi_geom` => Boolean (default: False) - specify as multigeometry.
"""
- if isinstance(data_source, six.string_types):
+ if isinstance(data_source, str):
# Instantiating the DataSource from the string.
data_source = DataSource(data_source)
elif isinstance(data_source, DataSource):
@@ -129,7 +128,7 @@ def _ogrinspect(data_source, model_name, geom_name='geom', layer_key=0, srid=Non
to the given data source. See the `ogrinspect` docstring for more details.
"""
# Getting the DataSource
- if isinstance(data_source, six.string_types):
+ if isinstance(data_source, str):
data_source = DataSource(data_source)
elif isinstance(data_source, DataSource):
pass
diff --git a/django/contrib/messages/storage/session.py b/django/contrib/messages/storage/session.py
index 624de42b8c..2eb8024bfa 100644
--- a/django/contrib/messages/storage/session.py
+++ b/django/contrib/messages/storage/session.py
@@ -5,7 +5,6 @@ from django.contrib.messages.storage.base import BaseStorage
from django.contrib.messages.storage.cookie import (
MessageDecoder, MessageEncoder,
)
-from django.utils import six
class SessionStorage(BaseStorage):
@@ -44,6 +43,6 @@ class SessionStorage(BaseStorage):
return encoder.encode(messages)
def deserialize_messages(self, data):
- if data and isinstance(data, six.string_types):
+ if data and isinstance(data, str):
return json.loads(data, cls=MessageDecoder)
return data
diff --git a/django/contrib/postgres/fields/array.py b/django/contrib/postgres/fields/array.py
index b70ae37a3a..dc5b9b8d6b 100644
--- a/django/contrib/postgres/fields/array.py
+++ b/django/contrib/postgres/fields/array.py
@@ -6,7 +6,6 @@ from django.contrib.postgres.validators import ArrayMaxLengthValidator
from django.core import checks, exceptions
from django.db.models import Field, IntegerField, Transform
from django.db.models.lookups import Exact, In
-from django.utils import six
from django.utils.translation import ugettext_lazy as _
from ..utils import prefix_validation_error
@@ -98,7 +97,7 @@ class ArrayField(Field):
return name, path, args, kwargs
def to_python(self, value):
- if isinstance(value, six.string_types):
+ if isinstance(value, str):
# Assume we're deserializing
vals = json.loads(value)
value = [self.base_field.to_python(val) for val in vals]
diff --git a/django/contrib/postgres/fields/hstore.py b/django/contrib/postgres/fields/hstore.py
index 605deaf62c..fcd212bc4a 100644
--- a/django/contrib/postgres/fields/hstore.py
+++ b/django/contrib/postgres/fields/hstore.py
@@ -4,7 +4,6 @@ from django.contrib.postgres import forms, lookups
from django.contrib.postgres.fields.array import ArrayField
from django.core import exceptions
from django.db.models import Field, TextField, Transform
-from django.utils import six
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _
@@ -30,7 +29,7 @@ class HStoreField(Field):
def validate(self, value, model_instance):
super(HStoreField, self).validate(value, model_instance)
for key, val in value.items():
- if not isinstance(val, six.string_types) and val is not None:
+ if not isinstance(val, str) and val is not None:
raise exceptions.ValidationError(
self.error_messages['not_a_string'],
code='not_a_string',
@@ -38,7 +37,7 @@ class HStoreField(Field):
)
def to_python(self, value):
- if isinstance(value, six.string_types):
+ if isinstance(value, str):
value = json.loads(value)
return value
diff --git a/django/contrib/postgres/fields/ranges.py b/django/contrib/postgres/fields/ranges.py
index ab7708d288..840417a58f 100644
--- a/django/contrib/postgres/fields/ranges.py
+++ b/django/contrib/postgres/fields/ranges.py
@@ -4,7 +4,6 @@ from psycopg2.extras import DateRange, DateTimeTZRange, NumericRange, Range
from django.contrib.postgres import forms, lookups
from django.db import models
-from django.utils import six
from .utils import AttributeSetter
@@ -45,7 +44,7 @@ class RangeField(models.Field):
return value
def to_python(self, value):
- if isinstance(value, six.string_types):
+ if isinstance(value, str):
# Assume we're deserializing
vals = json.loads(value)
for end in ('lower', 'upper'):
diff --git a/django/contrib/postgres/forms/array.py b/django/contrib/postgres/forms/array.py
index 9830c8de48..9a9e871a43 100644
--- a/django/contrib/postgres/forms/array.py
+++ b/django/contrib/postgres/forms/array.py
@@ -6,7 +6,6 @@ from django.contrib.postgres.validators import (
ArrayMaxLengthValidator, ArrayMinLengthValidator,
)
from django.core.exceptions import ValidationError
-from django.utils import six
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
@@ -31,7 +30,7 @@ class SimpleArrayField(forms.CharField):
def prepare_value(self, value):
if isinstance(value, list):
- return self.delimiter.join(six.text_type(self.base_field.prepare_value(v)) for v in value)
+ return self.delimiter.join(str(self.base_field.prepare_value(v)) for v in value)
return value
def to_python(self, value):
diff --git a/django/contrib/postgres/forms/hstore.py b/django/contrib/postgres/forms/hstore.py
index 76d362999d..25dceb9fb0 100644
--- a/django/contrib/postgres/forms/hstore.py
+++ b/django/contrib/postgres/forms/hstore.py
@@ -2,7 +2,6 @@ import json
from django import forms
from django.core.exceptions import ValidationError
-from django.utils import six
from django.utils.translation import ugettext_lazy as _
__all__ = ['HStoreField']
@@ -44,7 +43,7 @@ class HStoreField(forms.CharField):
# Cast everything to strings for ease.
for key, val in value.items():
if val is not None:
- val = six.text_type(val)
+ val = str(val)
value[key] = val
return value
diff --git a/django/contrib/postgres/forms/jsonb.py b/django/contrib/postgres/forms/jsonb.py
index 719de3ae66..28429c7172 100644
--- a/django/contrib/postgres/forms/jsonb.py
+++ b/django/contrib/postgres/forms/jsonb.py
@@ -1,17 +1,16 @@
import json
from django import forms
-from django.utils import six
from django.utils.translation import ugettext_lazy as _
__all__ = ['JSONField']
-class InvalidJSONInput(six.text_type):
+class InvalidJSONInput(str):
pass
-class JSONString(six.text_type):
+class JSONString(str):
pass
@@ -36,7 +35,7 @@ class JSONField(forms.CharField):
code='invalid',
params={'value': value},
)
- if isinstance(converted, six.text_type):
+ if isinstance(converted, str):
return JSONString(converted)
else:
return converted