mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-25 02:51:13 +00:00
Fix new warnings from pylint upgrade
This commit is contained in:
parent
c32f9faaa0
commit
acae063652
6 changed files with 21 additions and 26 deletions
|
@ -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]
|
||||
|
||||
|
||||
|
|
|
@ -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]:
|
||||
|
|
|
@ -169,7 +169,7 @@ class ActivitypubMixin:
|
|||
# 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)
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
@ -62,6 +62,6 @@ class HtmlValidator(HTMLParser): # pylint: disable=abstract-method
|
|||
and "noreferrer" in value
|
||||
):
|
||||
return
|
||||
raise Exception(
|
||||
raise ValueError(
|
||||
'Links to a new tab must have rel="nofollow noopener noreferrer"'
|
||||
)
|
||||
|
|
|
@ -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}}
|
||||
|
|
Loading…
Reference in a new issue