From 6f48143f4c60c555b3f571007cdc929ce90920b1 Mon Sep 17 00:00:00 2001 From: Ben Sturmfels Date: Thu, 23 Sep 2021 11:51:04 +1000 Subject: Apply pyupgrade --py36-plus. This removes some 'u' prefixes and converts simple format() calls to f-strings. --- mediagoblin/db/migrations.py | 4 ++-- mediagoblin/db/mixin.py | 2 +- mediagoblin/db/models.py | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'mediagoblin/db') diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py index 6c5b027c..f00c8019 100644 --- a/mediagoblin/db/migrations.py +++ b/mediagoblin/db/migrations.py @@ -425,9 +425,9 @@ class Client_v0(declarative_base()): def __repr__(self): if self.application_name: - return "".format(self.application_name, self.id) + return f"" else: - return "".format(self.id) + return f"" class RequestToken_v0(declarative_base()): """ diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py index 1a47c46f..dd78c791 100644 --- a/mediagoblin/db/mixin.py +++ b/mediagoblin/db/mixin.py @@ -188,7 +188,7 @@ class GenerateSlugMixin: # Can we just append the object's id to the end? if self.id: - slug_with_id = "{}-{}".format(slug, self.id) + slug_with_id = f"{slug}-{self.id}" if not self.check_slug_used(slug_with_id): self.slug = slug_with_id return # success! diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index c5809185..e65690fe 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -290,7 +290,7 @@ class User(Base, UserMixin): # Delete user, pass through commit=False/True in kwargs username = self.username super().delete(*args, **kwargs) - _log.info('Deleted user "{}" account'.format(username)) + _log.info(f'Deleted user "{username}" account') def has_privilege(self, privilege, allow_admin=True): """ @@ -389,7 +389,7 @@ class LocalUser(User): self.username) def get_public_id(self, host): - return "acct:{}@{}".format(self.username, host) + return f"acct:{self.username}@{host}" def serialize(self, request): user = { @@ -464,9 +464,9 @@ class Client(Base): def __repr__(self): if self.application_name: - return "".format(self.application_name, self.id) + return f"" else: - return "".format(self.id) + return f"" class RequestToken(Base): """ @@ -738,7 +738,7 @@ class MediaEntry(Base, MediaEntryMixin, CommentingMixin): # Returns list of files we failed to delete _log.error('No such files from the user "{1}" to delete: ' '{0}'.format(str(error), self.get_actor)) - _log.info('Deleted Media entry id "{}"'.format(self.id)) + _log.info(f'Deleted Media entry id "{self.id}"') # Related MediaTag's are automatically cleaned, but we might # want to clean out unused Tag's too. if del_orphan_tags: @@ -858,7 +858,7 @@ class FileKeynames(Base): name = Column(Unicode, unique=True) def __repr__(self): - return "".format(self.id, self.name) + return f"" @classmethod def find_or_new(cls, name): @@ -887,7 +887,7 @@ class MediaFile(Base): {}) def __repr__(self): - return "".format(self.name, self.file_path) + return f"" name_helper = relationship(FileKeynames, lazy="joined", innerjoin=True) name = association_proxy('name_helper', 'name', @@ -935,7 +935,7 @@ class Tag(Base): slug = Column(Unicode, nullable=False, unique=True) def __repr__(self): - return "".format(self.id, self.slug) + return f"" @classmethod def find_or_new(cls, slug): @@ -1034,7 +1034,7 @@ class Comment(Base): # fetch it from self.comment() raise AttributeError try: - _log.debug('Old attr is being accessed: {}'.format(attr)) + _log.debug(f'Old attr is being accessed: {attr}') return getattr(self.comment(), attr) # noqa except Exception as e: _log.error(e) -- cgit v1.2.3