From 08f6a9765379ab96cbf8348024923ea8a24e8254 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 18 Sep 2021 11:33:43 -0700 Subject: [PATCH] Python formatting --- bookwyrm/activitystreams.py | 4 +++- bookwyrm/connectors/abstract_connector.py | 4 +--- bookwyrm/connectors/inventaire.py | 10 ++-------- bookwyrm/emailing.py | 12 +++--------- bookwyrm/forms.py | 5 +---- bookwyrm/models/fields.py | 2 +- bookwyrm/models/status.py | 2 +- bookwyrm/models/user.py | 4 +--- bookwyrm/preview_images.py | 2 +- bookwyrm/settings.py | 4 +++- 10 files changed, 17 insertions(+), 32 deletions(-) diff --git a/bookwyrm/activitystreams.py b/bookwyrm/activitystreams.py index 13d56f84..c2b3da5e 100644 --- a/bookwyrm/activitystreams.py +++ b/bookwyrm/activitystreams.py @@ -20,7 +20,9 @@ class ActivityStream(RedisStore): def unread_id(self, user): """the redis key for this user's unread count for this stream""" - return "{}-unread".format(self.stream_id(user)) # pylint: disable=consider-using-f-string + return "{}-unread".format( + self.stream_id(user) + ) # pylint: disable=consider-using-f-string def get_rank(self, obj): # pylint: disable=no-self-use """statuses are sorted by date published""" diff --git a/bookwyrm/connectors/abstract_connector.py b/bookwyrm/connectors/abstract_connector.py index 902ccd6c..455241cc 100644 --- a/bookwyrm/connectors/abstract_connector.py +++ b/bookwyrm/connectors/abstract_connector.py @@ -222,9 +222,7 @@ def get_data(url, params=None, timeout=10): """wrapper for request.get""" # check if the url is blocked if models.FederatedServer.is_blocked(url): - raise ConnectorException( - f"Attempting to load data from blocked url: {url}" - ) + raise ConnectorException(f"Attempting to load data from blocked url: {url}") try: resp = requests.get( diff --git a/bookwyrm/connectors/inventaire.py b/bookwyrm/connectors/inventaire.py index b23a7d52..70455488 100644 --- a/bookwyrm/connectors/inventaire.py +++ b/bookwyrm/connectors/inventaire.py @@ -87,11 +87,7 @@ class Connector(AbstractConnector): def format_search_result(self, search_result): images = search_result.get("image") - cover = ( - f"{self.covers_url}/img/entities/{images[0]}" - if images - else None - ) + cover = f"{self.covers_url}/img/entities/{images[0]}" if images else None # a deeply messy translation of inventaire's scores confidence = float(search_result.get("_score", 0.1)) confidence = 0.1 if confidence < 150 else 0.999 @@ -131,9 +127,7 @@ class Connector(AbstractConnector): def load_edition_data(self, work_uri): """get a list of editions for a work""" - url = ( - f"{self.books_url}?action=reverse-claims&property=wdt:P629&value={work_uri}&sort=true" - ) + url = f"{self.books_url}?action=reverse-claims&property=wdt:P629&value={work_uri}&sort=true" return get_data(url) def get_edition_from_work_data(self, data): diff --git a/bookwyrm/emailing.py b/bookwyrm/emailing.py index 10db4f13..c6a197f2 100644 --- a/bookwyrm/emailing.py +++ b/bookwyrm/emailing.py @@ -48,18 +48,12 @@ def password_reset_email(reset_code): def format_email(email_name, data): """render the email templates""" - subject = ( - get_template(f"email/{email_name}/subject.html").render(data).strip() - ) + subject = get_template(f"email/{email_name}/subject.html").render(data).strip() html_content = ( - get_template(f"email/{email_name}/html_content.html") - .render(data) - .strip() + get_template(f"email/{email_name}/html_content.html").render(data).strip() ) text_content = ( - get_template(f"email/{email_name}/text_content.html") - .render(data) - .strip() + get_template(f"email/{email_name}/text_content.html").render(data).strip() ) return (subject, html_content, text_content) diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index d8228b7e..23063ff7 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -260,10 +260,7 @@ class CreateInviteForm(CustomForm): ] ), "use_limit": widgets.Select( - choices=[ - (i, _(f"{i} uses")) - for i in [1, 5, 10, 25, 50, 100] - ] + choices=[(i, _(f"{i} uses")) for i in [1, 5, 10, 25, 50, 100]] + [(None, _("Unlimited"))] ), } diff --git a/bookwyrm/models/fields.py b/bookwyrm/models/fields.py index 8555e06f..ccd669cb 100644 --- a/bookwyrm/models/fields.py +++ b/bookwyrm/models/fields.py @@ -56,7 +56,7 @@ class ActivitypubFieldMixin: activitypub_field=None, activitypub_wrapper=None, deduplication_field=False, - **kwargs + **kwargs, ): self.deduplication_field = deduplication_field if activitypub_wrapper: diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index 0b6e49e2..e3a3d387 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -181,7 +181,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): self.replies(self), remote_id=f"{self.remote_id}/replies", collection_only=True, - **kwargs + **kwargs, ).serialize() def to_activity_dataclass(self, pure=False): # pylint: disable=arguments-differ diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index 750cfa44..ad43270c 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -198,9 +198,7 @@ class User(OrderedCollectionPageMixin, AbstractUser): def to_outbox(self, filter_type=None, **kwargs): """an ordered collection of statuses""" if filter_type: - filter_class = apps.get_model( - f"bookwyrm.{filter_type}", require_ready=True - ) + filter_class = apps.get_model(f"bookwyrm.{filter_type}", require_ready=True) if not issubclass(filter_class, Status): raise TypeError( "filter_status_class must be a subclass of models.Status" diff --git a/bookwyrm/preview_images.py b/bookwyrm/preview_images.py index c9ef4643..55af3532 100644 --- a/bookwyrm/preview_images.py +++ b/bookwyrm/preview_images.py @@ -413,7 +413,7 @@ def generate_user_preview_image_task(user_id): texts = { "text_one": user.display_name, - "text_three": "@{user.localname}@{settings.DOMAIN}" + "text_three": "@{user.localname}@{settings.DOMAIN}", } if user.avatar: diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py index c6a816ed..285d2df8 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -23,7 +23,9 @@ EMAIL_HOST_USER = env("EMAIL_HOST_USER") EMAIL_HOST_PASSWORD = env("EMAIL_HOST_PASSWORD") EMAIL_USE_TLS = env.bool("EMAIL_USE_TLS", True) EMAIL_USE_SSL = env.bool("EMAIL_USE_SSL", False) -DEFAULT_FROM_EMAIL = "admin@{:s}".format(env("DOMAIN")) # pylint: disable=consider-using-f-string +DEFAULT_FROM_EMAIL = "admin@{:s}".format( + env("DOMAIN") +) # pylint: disable=consider-using-f-string # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))