Skip to content

Commit 67ed8bc

Browse files
committed
[#142] upgrade old syntax
1 parent b352dc8 commit 67ed8bc

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

django_redshift_backend/base.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
Requires psycopg 2: http://initd.org/projects/psycopg2
55
"""
66

7-
from __future__ import absolute_import
8-
97
from copy import deepcopy
108
import re
119
import uuid
@@ -121,7 +119,7 @@ def sequence_reset_sql(self, style, model_list):
121119
return []
122120

123121
def get_db_converters(self, expression):
124-
converters = super(DatabaseOperations, self).get_db_converters(expression)
122+
converters = super().get_db_converters(expression)
125123
internal_type = expression.output_field.get_internal_type()
126124
if internal_type == "UUIDField":
127125
converters.append(self.convert_uuidfield_value)
@@ -139,7 +137,7 @@ def distinct_sql(self, fields, *args):
139137
raise NotSupportedError(
140138
"DISTINCT ON fields is not supported by this database backend"
141139
)
142-
return super(DatabaseOperations, self).distinct_sql(fields, *args)
140+
return super().distinct_sql(fields, *args)
143141

144142
def adapt_integerfield_value(self, value, internal_type):
145143
return value
@@ -278,7 +276,7 @@ def create_model(self, model):
278276
if m:
279277
definition = re.sub(
280278
r"varchar\((\d+?)\)",
281-
"varchar({0})".format(
279+
"varchar({})".format(
282280
str(int(m.group(1)) * self.multiply_varchar_length)
283281
),
284282
definition,
@@ -1058,7 +1056,7 @@ def quoted_column_name(field_name):
10581056
if isinstance(idx, DistKey):
10591057
if distkey:
10601058
raise ValueError(
1061-
"Model {} has more than one DistKey.".format(model.__name__)
1059+
f"Model {model.__name__} has more than one DistKey."
10621060
)
10631061
distkey = idx
10641062
if distkey:
@@ -1072,7 +1070,7 @@ def quoted_column_name(field_name):
10721070
)
10731071
)
10741072
normalized_field = quoted_column_name(distkey.fields[0])
1075-
create_options.append("DISTKEY({})".format(normalized_field))
1073+
create_options.append(f"DISTKEY({normalized_field})")
10761074
# TODO: Support DISTSTYLE ALL.
10771075

10781076
sortkeys = [
@@ -1368,7 +1366,7 @@ class DatabaseWrapper(BasePGDatabaseWrapper):
13681366
data_types.update(redshift_data_types)
13691367

13701368
def __init__(self, *args, **kwargs):
1371-
super(DatabaseWrapper, self).__init__(*args, **kwargs)
1369+
super().__init__(*args, **kwargs)
13721370

13731371
self.atomic_blocks = []
13741372
self.features = DatabaseFeatures(self)

django_redshift_backend/meta.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __hash__(self):
3737
return hash(str(self))
3838

3939
def deconstruct(self):
40-
path = "%s.%s" % (self.__class__.__module__, self.__class__.__name__)
40+
path = "{}.{}".format(self.__class__.__module__, self.__class__.__name__)
4141
path = path.replace("django_redshift_backend.meta", "django_redshift_backend")
4242
return (path, [str(self)], {})
4343

0 commit comments

Comments
 (0)