Skip to content

Commit

Permalink
Fix new warnings from pylint upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Minnozz committed Apr 26, 2024
1 parent c32f9fa commit acae063
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 26 deletions.
10 changes: 5 additions & 5 deletions bookwyrm/activitypub/base_activity.py
Expand Up @@ -400,11 +400,11 @@ def get_representative():
to sign outgoing HTTP GET requests"""
return models.User.objects.get_or_create(
username=f"{INSTANCE_ACTOR_USERNAME}@{DOMAIN}",
defaults=dict(
email="bookwyrm@localhost",
local=True,
localname=INSTANCE_ACTOR_USERNAME,
),
defaults={
"email": "bookwyrm@localhost",
"local": True,
"localname": INSTANCE_ACTOR_USERNAME,
},
)[0]


Expand Down
13 changes: 4 additions & 9 deletions bookwyrm/importers/calibre_import.py
Expand Up @@ -14,15 +14,10 @@ class CalibreImporter(Importer):
def __init__(self, *args: Any, **kwargs: Any):
# Add timestamp to row_mappings_guesses for date_added to avoid
# integrity error
row_mappings_guesses = []

for field, mapping in self.row_mappings_guesses:
if field in ("date_added",):
row_mappings_guesses.append((field, mapping + ["timestamp"]))
else:
row_mappings_guesses.append((field, mapping))

self.row_mappings_guesses = row_mappings_guesses
self.row_mappings_guesses = [
(field, mapping + (["timestamp"] if field == "date_added" else []))
for field, mapping in self.row_mappings_guesses
]
super().__init__(*args, **kwargs)

def get_shelf(self, normalized_row: dict[str, Optional[str]]) -> Optional[str]:
Expand Down
2 changes: 1 addition & 1 deletion bookwyrm/models/activitypub_mixin.py
Expand Up @@ -169,7 +169,7 @@ def get_recipients(self, software=None) -> list[str]:
# filter users first by whether they're using the desired software
# this lets us send book updates only to other bw servers
if software:
queryset = queryset.filter(bookwyrm_user=(software == "bookwyrm"))
queryset = queryset.filter(bookwyrm_user=software == "bookwyrm")
# if there's a user, we only want to send to the user's followers
if user:
queryset = queryset.filter(following=user)
Expand Down
16 changes: 8 additions & 8 deletions bookwyrm/templatetags/utilities.py
Expand Up @@ -137,14 +137,14 @@ def get_file_size(nbytes):
raw_size = float(nbytes)
except (ValueError, TypeError):
return repr(nbytes)
else:
if raw_size < 1024:
return f"{raw_size} bytes"
if raw_size < 1024**2:
return f"{raw_size/1024:.2f} KB"
if raw_size < 1024**3:
return f"{raw_size/1024**2:.2f} MB"
return f"{raw_size/1024**3:.2f} GB"

if raw_size < 1024:
return f"{raw_size} bytes"
if raw_size < 1024**2:
return f"{raw_size/1024:.2f} KB"
if raw_size < 1024**3:
return f"{raw_size/1024**2:.2f} MB"
return f"{raw_size/1024**3:.2f} GB"


@register.filter(name="get_user_permission")
Expand Down
4 changes: 2 additions & 2 deletions bookwyrm/tests/validate_html.py
Expand Up @@ -35,7 +35,7 @@ def validate_html(html):
e for e in errors.split("\n") if not any(exclude in e for exclude in excluded)
)
if errors:
raise Exception(errors)
raise ValueError(errors)

validator = HtmlValidator()
# will raise exceptions
Expand All @@ -62,6 +62,6 @@ def handle_starttag(self, tag, attrs):
and "noreferrer" in value
):
return
raise Exception(
raise ValueError(
'Links to a new tab must have rel="nofollow noopener noreferrer"'
)
2 changes: 1 addition & 1 deletion bookwyrm/views/annual_summary.py
Expand Up @@ -225,4 +225,4 @@ def get_goal_status(user, year):
if goal.privacy != "public":
return None

return dict(**goal.progress, **{"goal": goal.goal})
return {**goal.progress, **{"goal": goal.goal}}

0 comments on commit acae063

Please sign in to comment.