mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-02-16 11:05:15 +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"""
|
to sign outgoing HTTP GET requests"""
|
||||||
return models.User.objects.get_or_create(
|
return models.User.objects.get_or_create(
|
||||||
username=f"{INSTANCE_ACTOR_USERNAME}@{DOMAIN}",
|
username=f"{INSTANCE_ACTOR_USERNAME}@{DOMAIN}",
|
||||||
defaults=dict(
|
defaults={
|
||||||
email="bookwyrm@localhost",
|
"email": "bookwyrm@localhost",
|
||||||
local=True,
|
"local": True,
|
||||||
localname=INSTANCE_ACTOR_USERNAME,
|
"localname": INSTANCE_ACTOR_USERNAME,
|
||||||
),
|
},
|
||||||
)[0]
|
)[0]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,15 +14,10 @@ class CalibreImporter(Importer):
|
||||||
def __init__(self, *args: Any, **kwargs: Any):
|
def __init__(self, *args: Any, **kwargs: Any):
|
||||||
# Add timestamp to row_mappings_guesses for date_added to avoid
|
# Add timestamp to row_mappings_guesses for date_added to avoid
|
||||||
# integrity error
|
# integrity error
|
||||||
row_mappings_guesses = []
|
self.row_mappings_guesses = [
|
||||||
|
(field, mapping + (["timestamp"] if field == "date_added" else []))
|
||||||
for field, mapping in self.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
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def get_shelf(self, normalized_row: dict[str, Optional[str]]) -> Optional[str]:
|
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
|
# filter users first by whether they're using the desired software
|
||||||
# this lets us send book updates only to other bw servers
|
# this lets us send book updates only to other bw servers
|
||||||
if software:
|
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 there's a user, we only want to send to the user's followers
|
||||||
if user:
|
if user:
|
||||||
queryset = queryset.filter(following=user)
|
queryset = queryset.filter(following=user)
|
||||||
|
|
|
@ -137,14 +137,14 @@ def get_file_size(nbytes):
|
||||||
raw_size = float(nbytes)
|
raw_size = float(nbytes)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
return repr(nbytes)
|
return repr(nbytes)
|
||||||
else:
|
|
||||||
if raw_size < 1024:
|
if raw_size < 1024:
|
||||||
return f"{raw_size} bytes"
|
return f"{raw_size} bytes"
|
||||||
if raw_size < 1024**2:
|
if raw_size < 1024**2:
|
||||||
return f"{raw_size/1024:.2f} KB"
|
return f"{raw_size/1024:.2f} KB"
|
||||||
if raw_size < 1024**3:
|
if raw_size < 1024**3:
|
||||||
return f"{raw_size/1024**2:.2f} MB"
|
return f"{raw_size/1024**2:.2f} MB"
|
||||||
return f"{raw_size/1024**3:.2f} GB"
|
return f"{raw_size/1024**3:.2f} GB"
|
||||||
|
|
||||||
|
|
||||||
@register.filter(name="get_user_permission")
|
@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)
|
e for e in errors.split("\n") if not any(exclude in e for exclude in excluded)
|
||||||
)
|
)
|
||||||
if errors:
|
if errors:
|
||||||
raise Exception(errors)
|
raise ValueError(errors)
|
||||||
|
|
||||||
validator = HtmlValidator()
|
validator = HtmlValidator()
|
||||||
# will raise exceptions
|
# will raise exceptions
|
||||||
|
@ -62,6 +62,6 @@ class HtmlValidator(HTMLParser): # pylint: disable=abstract-method
|
||||||
and "noreferrer" in value
|
and "noreferrer" in value
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
raise Exception(
|
raise ValueError(
|
||||||
'Links to a new tab must have rel="nofollow noopener noreferrer"'
|
'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":
|
if goal.privacy != "public":
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return dict(**goal.progress, **{"goal": goal.goal})
|
return {**goal.progress, **{"goal": goal.goal}}
|
||||||
|
|
Loading…
Reference in a new issue