mirror of
https://github.com/jazzband/django-constance.git
synced 2026-03-16 22:40:24 +00:00
chore: migrate to f-string
fix: use str() instead of f-string credit: tool pyupgrade Co-Authored-By: Alexandr Artemyev <mogost@gmail.com>
This commit is contained in:
parent
053944200e
commit
eb5aef2554
4 changed files with 7 additions and 7 deletions
|
|
@ -199,11 +199,11 @@ class Config:
|
|||
|
||||
@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()
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class DatabaseBackend(Backend):
|
|||
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:
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class RedisBackend(Backend):
|
|||
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))
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class Command(BaseCommand):
|
|||
|
||||
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")
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ class Command(BaseCommand):
|
|||
|
||||
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':
|
||||
|
||||
|
|
@ -91,6 +91,6 @@ class Command(BaseCommand):
|
|||
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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue