From 8cf7e4405d90f78bd9a4c8c2cc4233b610b27d66 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 16 Oct 2020 19:13:18 -0700 Subject: [PATCH] minor style fixes --- bookwyrm/activitypub/base_activity.py | 9 ++++----- bookwyrm/activitypub/book.py | 1 - bookwyrm/activitypub/note.py | 2 +- bookwyrm/broadcast.py | 3 --- bookwyrm/emailing.py | 1 - bookwyrm/urls.py | 9 ++++++++- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/bookwyrm/activitypub/base_activity.py b/bookwyrm/activitypub/base_activity.py index 042b8a14..1cffd0ed 100644 --- a/bookwyrm/activitypub/base_activity.py +++ b/bookwyrm/activitypub/base_activity.py @@ -44,10 +44,9 @@ class ActivityObject: type: str def __init__(self, **kwargs): - ''' this lets you pass in an object with fields - that aren't in the dataclass, which it ignores. - Any field in the dataclass is required or has a - default value ''' + ''' this lets you pass in an object with fields that aren't in the + dataclass, which it ignores. Any field in the dataclass is required or + has a default value ''' for field in fields(self): try: value = kwargs[field.name] @@ -59,7 +58,7 @@ class ActivityObject: def to_model(self, model, instance=None): - ''' convert from an activity to a model ''' + ''' convert from an activity to a model instance ''' if not isinstance(self, model.activity_serializer): raise TypeError('Wrong activity type for model') diff --git a/bookwyrm/activitypub/book.py b/bookwyrm/activitypub/book.py index 2a50dd6a..49f2deb8 100644 --- a/bookwyrm/activitypub/book.py +++ b/bookwyrm/activitypub/book.py @@ -52,7 +52,6 @@ class Work(Book): type: str = 'Work' - @dataclass(init=False) class Author(ActivityObject): ''' author of a book ''' diff --git a/bookwyrm/activitypub/note.py b/bookwyrm/activitypub/note.py index 54730fb6..4e36b01f 100644 --- a/bookwyrm/activitypub/note.py +++ b/bookwyrm/activitypub/note.py @@ -6,6 +6,7 @@ from .base_activity import ActivityObject, Image @dataclass(init=False) class Tombstone(ActivityObject): + ''' the placeholder for a deleted status ''' url: str published: str deleted: str @@ -23,7 +24,6 @@ class Note(ActivityObject): cc: List[str] content: str replies: Dict - # TODO: this is wrong??? attachment: List[Image] = field(default=lambda: []) sensitive: bool = False type: str = 'Note' diff --git a/bookwyrm/broadcast.py b/bookwyrm/broadcast.py index 301fe84f..9b071b39 100644 --- a/bookwyrm/broadcast.py +++ b/bookwyrm/broadcast.py @@ -13,7 +13,6 @@ def get_public_recipients(user, software=None): ''' everybody and their public inboxes ''' followers = user.followers.filter(local=False) if software: - # TODO: eventually we may want to handle particular software differently followers = followers.filter(bookwyrm_user=(software == 'bookwyrm')) # we want shared inboxes when available @@ -36,7 +35,6 @@ def broadcast(sender, activity, software=None, \ # start with parsing the direct recipients recipients = [u.inbox for u in direct_recipients or []] # and then add any other recipients - # TODO: other kinds of privacy if privacy == 'public': recipients += get_public_recipients(sender, software=software) broadcast_task.delay( @@ -55,7 +53,6 @@ def broadcast_task(sender_id, activity, recipients): try: sign_and_send(sender, activity, recipient) except requests.exceptions.HTTPError as e: - # TODO: maybe keep track of users who cause errors errors.append({ 'error': str(e), 'recipient': recipient, diff --git a/bookwyrm/emailing.py b/bookwyrm/emailing.py index 12dee65f..2319d467 100644 --- a/bookwyrm/emailing.py +++ b/bookwyrm/emailing.py @@ -6,7 +6,6 @@ from bookwyrm.tasks import app def password_reset_email(reset_code): ''' generate a password reset email ''' - # TODO; this should be tempalted site = models.SiteSettings.get() send_email.delay( reset_code.user.email, diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 331efee5..5d75f49b 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -11,7 +11,14 @@ localname_regex = r'(?P[\w\-_]+)' user_path = r'^user/%s' % username_regex local_user_path = r'^user/%s' % localname_regex -status_types = ['status', 'review', 'comment', 'quotation', 'boost', 'generatedstatus'] +status_types = [ + 'status', + 'review', + 'comment', + 'quotation', + 'boost', + 'generatedstatus' +] status_path = r'%s/(%s)/(?P\d+)' % \ (local_user_path, '|'.join(status_types))