Skip to content

Commit

Permalink
[#142] upgrade old syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
shimizukawa committed Nov 23, 2024
1 parent b352dc8 commit 9740e2f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions django_redshift_backend/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Requires psycopg 2: http://initd.org/projects/psycopg2
"""

from __future__ import absolute_import

from copy import deepcopy
import re
Expand Down Expand Up @@ -121,7 +120,7 @@ def sequence_reset_sql(self, style, model_list):
return []

def get_db_converters(self, expression):
converters = super(DatabaseOperations, self).get_db_converters(expression)
converters = super().get_db_converters(expression)
internal_type = expression.output_field.get_internal_type()
if internal_type == "UUIDField":
converters.append(self.convert_uuidfield_value)
Expand All @@ -139,7 +138,7 @@ def distinct_sql(self, fields, *args):
raise NotSupportedError(
"DISTINCT ON fields is not supported by this database backend"
)
return super(DatabaseOperations, self).distinct_sql(fields, *args)
return super().distinct_sql(fields, *args)

def adapt_integerfield_value(self, value, internal_type):
return value
Expand Down Expand Up @@ -278,7 +277,7 @@ def create_model(self, model):
if m:
definition = re.sub(
r"varchar\((\d+?)\)",
"varchar({0})".format(
"varchar({})".format(
str(int(m.group(1)) * self.multiply_varchar_length)
),
definition,
Expand Down Expand Up @@ -1058,7 +1057,7 @@ def quoted_column_name(field_name):
if isinstance(idx, DistKey):
if distkey:
raise ValueError(
"Model {} has more than one DistKey.".format(model.__name__)
f"Model {model.__name__} has more than one DistKey."
)
distkey = idx
if distkey:
Expand All @@ -1072,7 +1071,7 @@ def quoted_column_name(field_name):
)
)
normalized_field = quoted_column_name(distkey.fields[0])
create_options.append("DISTKEY({})".format(normalized_field))
create_options.append(f"DISTKEY({normalized_field})")
# TODO: Support DISTSTYLE ALL.

sortkeys = [
Expand Down Expand Up @@ -1368,7 +1367,7 @@ class DatabaseWrapper(BasePGDatabaseWrapper):
data_types.update(redshift_data_types)

def __init__(self, *args, **kwargs):
super(DatabaseWrapper, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

self.atomic_blocks = []
self.features = DatabaseFeatures(self)
Expand Down
2 changes: 1 addition & 1 deletion django_redshift_backend/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __hash__(self):
return hash(str(self))

def deconstruct(self):
path = "%s.%s" % (self.__class__.__module__, self.__class__.__name__)
path = "{}.{}".format(self.__class__.__module__, self.__class__.__name__)
path = path.replace("django_redshift_backend.meta", "django_redshift_backend")
return (path, [str(self)], {})

Expand Down

0 comments on commit 9740e2f

Please sign in to comment.