Skip to content

Commit 9740e2f

Browse files
committed
[#142] upgrade old syntax
1 parent b352dc8 commit 9740e2f

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

django_redshift_backend/base.py

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

7-
from __future__ import absolute_import
87

98
from copy import deepcopy
109
import re
@@ -121,7 +120,7 @@ def sequence_reset_sql(self, style, model_list):
121120
return []
122121

123122
def get_db_converters(self, expression):
124-
converters = super(DatabaseOperations, self).get_db_converters(expression)
123+
converters = super().get_db_converters(expression)
125124
internal_type = expression.output_field.get_internal_type()
126125
if internal_type == "UUIDField":
127126
converters.append(self.convert_uuidfield_value)
@@ -139,7 +138,7 @@ def distinct_sql(self, fields, *args):
139138
raise NotSupportedError(
140139
"DISTINCT ON fields is not supported by this database backend"
141140
)
142-
return super(DatabaseOperations, self).distinct_sql(fields, *args)
141+
return super().distinct_sql(fields, *args)
143142

144143
def adapt_integerfield_value(self, value, internal_type):
145144
return value
@@ -278,7 +277,7 @@ def create_model(self, model):
278277
if m:
279278
definition = re.sub(
280279
r"varchar\((\d+?)\)",
281-
"varchar({0})".format(
280+
"varchar({})".format(
282281
str(int(m.group(1)) * self.multiply_varchar_length)
283282
),
284283
definition,
@@ -1058,7 +1057,7 @@ def quoted_column_name(field_name):
10581057
if isinstance(idx, DistKey):
10591058
if distkey:
10601059
raise ValueError(
1061-
"Model {} has more than one DistKey.".format(model.__name__)
1060+
f"Model {model.__name__} has more than one DistKey."
10621061
)
10631062
distkey = idx
10641063
if distkey:
@@ -1072,7 +1071,7 @@ def quoted_column_name(field_name):
10721071
)
10731072
)
10741073
normalized_field = quoted_column_name(distkey.fields[0])
1075-
create_options.append("DISTKEY({})".format(normalized_field))
1074+
create_options.append(f"DISTKEY({normalized_field})")
10761075
# TODO: Support DISTSTYLE ALL.
10771076

10781077
sortkeys = [
@@ -1368,7 +1367,7 @@ class DatabaseWrapper(BasePGDatabaseWrapper):
13681367
data_types.update(redshift_data_types)
13691368

13701369
def __init__(self, *args, **kwargs):
1371-
super(DatabaseWrapper, self).__init__(*args, **kwargs)
1370+
super().__init__(*args, **kwargs)
13721371

13731372
self.atomic_blocks = []
13741373
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)