Use modern string formatting syntax in status model

This commit is contained in:
Mouse Reeve 2021-02-25 10:26:24 -08:00
parent ed7c13531f
commit ffd57dfef4

View file

@ -258,13 +258,12 @@ class Review(Status):
def pure_name(self): def pure_name(self):
''' clarify review names for mastodon serialization ''' ''' clarify review names for mastodon serialization '''
if self.rating: if self.rating:
#pylint: disable=bad-string-format-type return 'Review of "{}" ({:d} stars): {}'.format(
return 'Review of "%s" (%d stars): %s' % (
self.book.title, self.book.title,
self.rating, self.rating,
self.name self.name
) )
return 'Review of "%s": %s' % ( return 'Review of "{}": {}'.format(
self.book.title, self.book.title,
self.name self.name
) )
@ -282,13 +281,13 @@ class ReviewRating(Review):
''' a subtype of review that only contains a rating ''' ''' a subtype of review that only contains a rating '''
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
if not self.rating: if not self.rating:
raise ValueError('Rating object must include a numerical rating') raise ValueError(
'ReviewRating object must include a numerical rating')
return super().save(*args, **kwargs) return super().save(*args, **kwargs)
@property @property
def pure_content(self): def pure_content(self):
#pylint: disable=bad-string-format-type return 'Rated "{}": {:d} stars'.format(self.book.title, self.rating)
return 'Rated "%s": %d stars' % (self.book.title, self.rating)
activity_serializer = activitypub.Rating activity_serializer = activitypub.Rating
pure_type = 'Note' pure_type = 'Note'