in progress fixes for pylint

This commit is contained in:
Vivianne Langdon 2022-03-11 20:14:45 -08:00
parent 594fa5d058
commit f2d7bdbf27
6 changed files with 14 additions and 13 deletions

View file

@ -372,7 +372,7 @@ urlpatterns = [
# groups
re_path(rf"{USER_PATH}/groups/?$", views.UserGroups.as_view(), name="user-groups"),
re_path(
rf"^group/(?P<group_id>\d+)(.json)?/?$", views.Group.as_view(), name="group"
r"^group/(?P<group_id>\d+)(.json)?/?$", views.Group.as_view(), name="group"
),
re_path(
rf"^group/(?P<group_id>\d+){regex.SLUG}/?$", views.Group.as_view(), name="group"
@ -403,7 +403,7 @@ urlpatterns = [
re_path(rf"{USER_PATH}/lists/?$", views.UserLists.as_view(), name="user-lists"),
re_path(r"^list/?$", views.Lists.as_view(), name="lists"),
re_path(r"^list/saved/?$", views.SavedLists.as_view(), name="saved-lists"),
re_path(rf"^list/(?P<list_id>\d+)(\.json)?/?$", views.List.as_view(), name="list"),
re_path(r"^list/(?P<list_id>\d+)(\.json)?/?$", views.List.as_view(), name="list"),
re_path(
rf"^list/(?P<list_id>\d+){regex.SLUG}/?$", views.List.as_view(), name="list"
),
@ -560,7 +560,7 @@ urlpatterns = [
re_path(r"^isbn/(?P<isbn>\d+)(.json)?/?$", views.Isbn.as_view()),
# author
re_path(
rf"^author/(?P<author_id>\d+)(.json)?/?$", views.Author.as_view(), name="author"
r"^author/(?P<author_id>\d+)(.json)?/?$", views.Author.as_view(), name="author"
),
re_path(
rf"^author/(?P<author_id>\d+){regex.SLUG}/?$",

View file

@ -26,8 +26,8 @@ class Author(View):
if is_api_request(request):
return ActivitypubResponse(author.to_activity())
if r := maybe_redirect_local_path(request, author):
return r
if redirect := maybe_redirect_local_path(request, author):
return redirect
books = (
models.Work.objects.filter(Q(authors=author) | Q(editions__authors=author))

View file

@ -50,8 +50,8 @@ class Book(View):
if not book or not book.parent_work:
raise Http404()
if r := maybe_redirect_local_path(request, book):
return r
if redirect := maybe_redirect_local_path(request, book):
return redirect
# all reviews for all editions of the book
reviews = models.Review.privacy_filter(request.user).filter(

View file

@ -130,8 +130,8 @@ class Status(View):
status.to_activity(pure=not is_bookwyrm_request(request))
)
if r := maybe_redirect_local_path(request, status):
return r
if redirect := maybe_redirect_local_path(request, status):
return redirect
visible_thread = (
models.Status.privacy_filter(request.user)

View file

@ -26,8 +26,8 @@ class Group(View):
group = get_object_or_404(models.Group, id=group_id)
group.raise_visible_to_user(request.user)
if r := maybe_redirect_local_path(request, group):
return r
if redirect := maybe_redirect_local_path(request, group):
return redirect
lists = (
models.List.privacy_filter(request.user)

View file

@ -206,12 +206,13 @@ def filter_stream_by_status_type(activities, allowed_types=None):
def maybe_redirect_local_path(request, model):
"""
if the request had an invalid path, return a permanent redirect response to the correct one, including a slug if any.
if the request had an invalid path, return a permanent redirect response to the
correct one, including a slug if any.
if path is valid, returns False.
"""
# don't redirect empty path for unit tests which currently have this
if request.path == "/" or request.path == model.local_path:
if request.path in ("/", model.local_path):
return False
new_path = model.local_path