Skip to content

Commit

Permalink
chore: migrate to f-string
Browse files Browse the repository at this point in the history
fix: use str() instead of f-string

credit: tool pyupgrade
Co-Authored-By: Alexandr Artemyev <[email protected]>
  • Loading branch information
Rotzbua and Mogost committed Jun 9, 2024
1 parent 0539442 commit eb5aef2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions constance/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@ def app_config(self):

@property
def label(self):
return '%s.%s' % (self.app_label, self.object_name)
return f'{self.app_label}.{self.object_name}'

@property
def label_lower(self):
return '%s.%s' % (self.app_label, self.model_name)
return f'{self.app_label}.{self.model_name}'

_meta = Meta()

Expand Down
2 changes: 1 addition & 1 deletion constance/backends/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self):
post_save.connect(self.clear, sender=self._model)

def add_prefix(self, key):
return "%s%s" % (self._prefix, key)
return f"{self._prefix}{key}"

def autofill(self):
if not self._autofill_timeout or not self._cache:
Expand Down
2 changes: 1 addition & 1 deletion constance/backends/redisd.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self):
self._rd = redis.Redis(**settings.REDIS_CONNECTION)

def add_prefix(self, key):
return "%s%s" % (self._prefix, key)
return f"{self._prefix}{key}"

def get(self, key):
value = self._rd.get(self.add_prefix(key))
Expand Down
6 changes: 3 additions & 3 deletions constance/management/commands/constance.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def handle(self, command, key=None, value=None, *args, **options):

if command == 'get':
try:
self.stdout.write("{}".format(getattr(config, key)), ending="\n")
self.stdout.write(str(getattr(config, key)), ending="\n")
except AttributeError as e:
raise CommandError(key + " is not defined in settings.CONSTANCE_CONFIG")

Expand All @@ -78,7 +78,7 @@ def handle(self, command, key=None, value=None, *args, **options):

elif command == 'list':
for k, v in get_values().items():
self.stdout.write("{}\t{}".format(k, v), ending="\n")
self.stdout.write(f"{k}\t{v}", ending="\n")

elif command == 'remove_stale_keys':

Expand All @@ -91,6 +91,6 @@ def handle(self, command, key=None, value=None, *args, **options):
self.stdout.write("There are no stale records in database.", ending="\n")

for stale_record in stale_records:
self.stdout.write("{}\t{}".format(stale_record.key, stale_record.value), ending="\n")
self.stdout.write(f"{stale_record.key}\t{stale_record.value}", ending="\n")

stale_records.delete()

0 comments on commit eb5aef2

Please sign in to comment.