ruff rules UP008 and UP009

This commit is contained in:
thomas girod
2024-06-27 14:46:43 +02:00
parent 688871a680
commit cfc19434d0
258 changed files with 473 additions and 824 deletions

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
#
# Copyright 2019
# - Sli <antoine@bartuccio.fr>

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
#
# Copyright 2019
# - Sli <antoine@bartuccio.fr>

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
#
# Copyright 2019
# - Sli <antoine@bartuccio.fr>
@ -66,7 +65,7 @@ class UVForm(forms.ModelForm):
}
def __init__(self, author_id, *args, **kwargs):
super(UVForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.fields["author"].queryset = User.objects.filter(id=author_id).all()
self.fields["author"].initial = author_id
@ -75,11 +74,11 @@ class StarList(forms.NumberInput):
template_name = "pedagogy/starlist.jinja"
def __init__(self, nubmer_of_stars=0):
super(StarList, self).__init__(None)
super().__init__(None)
self.number_of_stars = nubmer_of_stars
def get_context(self, name, value, attrs):
context = super(StarList, self).get_context(name, value, attrs)
context = super().get_context(name, value, attrs)
context["number_of_stars"] = range(0, self.number_of_stars)
context["translations"] = {"do_not_vote": _("Do not vote")}
return context
@ -114,7 +113,7 @@ class UVCommentForm(forms.ModelForm):
}
def __init__(self, author_id, uv_id, is_creation, *args, **kwargs):
super(UVCommentForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.fields["author"].queryset = User.objects.filter(id=author_id).all()
self.fields["author"].initial = author_id
self.fields["uv"].queryset = UV.objects.filter(id=uv_id).all()
@ -122,7 +121,7 @@ class UVCommentForm(forms.ModelForm):
self.is_creation = is_creation
def clean(self):
self.cleaned_data = super(UVCommentForm, self).clean()
self.cleaned_data = super().clean()
uv = self.cleaned_data.get("uv")
author = self.cleaned_data.get("author")
@ -152,7 +151,7 @@ class UVCommentReportForm(forms.ModelForm):
}
def __init__(self, reporter_id, comment_id, *args, **kwargs):
super(UVCommentReportForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.fields["reporter"].queryset = User.objects.filter(id=reporter_id).all()
self.fields["reporter"].initial = reporter_id
self.fields["comment"].queryset = UVComment.objects.filter(id=comment_id).all()

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-07-05 14:32
from __future__ import unicode_literals

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
#
# Copyright 2019
# - Sli <antoine@bartuccio.fr>

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
#
# Copyright 2019
# - Sli <antoine@bartuccio.fr>
@ -272,7 +271,7 @@ class UVComment(models.Model):
def save(self, *args, **kwargs):
if self.publish_date is None:
self.publish_date = timezone.now()
super(UVComment, self).save(*args, **kwargs)
super().save(*args, **kwargs)
class UVResult(models.Model):

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
#
# Copyright 2019
# - Sli <antoine@bartuccio.fr>

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
#
# Copyright 2019
# - Sli <antoine@bartuccio.fr>

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
#
# Copyright 2019
# - Sli <antoine@bartuccio.fr>

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
#
# Copyright 2019
# - Sli <antoine@bartuccio.fr>
@ -73,7 +72,7 @@ class CanCreateUVFunctionMixin(View):
"""
Pass the function to the template
"""
kwargs = super(CanCreateUVFunctionMixin, self).get_context_data(**kwargs)
kwargs = super().get_context_data(**kwargs)
kwargs["can_create_uv"] = self.can_create_uv
return kwargs
@ -93,7 +92,7 @@ class UVDetailFormView(CanViewMixin, CanCreateUVFunctionMixin, DetailFormView):
form_class = UVCommentForm
def get_form_kwargs(self):
kwargs = super(UVDetailFormView, self).get_form_kwargs()
kwargs = super().get_form_kwargs()
kwargs["author_id"] = self.request.user.id
kwargs["uv_id"] = self.get_object().id
kwargs["is_creation"] = True
@ -101,7 +100,7 @@ class UVDetailFormView(CanViewMixin, CanCreateUVFunctionMixin, DetailFormView):
def form_valid(self, form):
form.save()
return super(UVDetailFormView, self).form_valid(form)
return super().form_valid(form)
def get_success_url(self):
return reverse_lazy(
@ -120,7 +119,7 @@ class UVCommentUpdateView(CanEditPropMixin, UpdateView):
template_name = "core/edit.jinja"
def get_form_kwargs(self):
kwargs = super(UVCommentUpdateView, self).get_form_kwargs()
kwargs = super().get_form_kwargs()
obj = self.get_object()
kwargs["author_id"] = obj.author.id
kwargs["uv_id"] = obj.uv.id
@ -159,7 +158,7 @@ class UVListView(CanViewMixin, CanCreateUVFunctionMixin, ListView):
def get(self, *args, **kwargs):
if not self.request.GET.get("json", None):
# Return normal full template response
return super(UVListView, self).get(*args, **kwargs)
return super().get(*args, **kwargs)
# Return serialized response
return HttpResponse(
@ -168,7 +167,7 @@ class UVListView(CanViewMixin, CanCreateUVFunctionMixin, ListView):
)
def get_queryset(self):
queryset = super(UVListView, self).get_queryset()
queryset = super().get_queryset()
search = self.request.GET.get("search", None)
additional_filters = {}
@ -219,16 +218,16 @@ class UVCommentReportCreateView(CanCreateMixin, CreateView):
def dispatch(self, request, *args, **kwargs):
self.uv_comment = get_object_or_404(UVComment, pk=kwargs["comment_id"])
return super(UVCommentReportCreateView, self).dispatch(request, *args, **kwargs)
return super().dispatch(request, *args, **kwargs)
def get_form_kwargs(self):
kwargs = super(UVCommentReportCreateView, self).get_form_kwargs()
kwargs = super().get_form_kwargs()
kwargs["reporter_id"] = self.request.user.id
kwargs["comment_id"] = self.uv_comment.id
return kwargs
def form_valid(self, form):
resp = super(UVCommentReportCreateView, self).form_valid(form)
resp = super().form_valid(form)
# Send a message to moderation admins
for user in (
@ -264,7 +263,7 @@ class UVModerationFormView(FormView):
def dispatch(self, request, *args, **kwargs):
if not request.user.is_owner(UV()):
raise PermissionDenied
return super(UVModerationFormView, self).dispatch(request, *args, **kwargs)
return super().dispatch(request, *args, **kwargs)
def form_valid(self, form):
form_clean = form.clean()
@ -280,7 +279,7 @@ class UVModerationFormView(FormView):
except ObjectDoesNotExist:
# To avoid errors when two reports points the same comment
pass
return super(UVModerationFormView, self).form_valid(form)
return super().form_valid(form)
def get_success_url(self):
return reverse_lazy("pedagogy:moderation")
@ -296,7 +295,7 @@ class UVCreateView(CanCreateMixin, CreateView):
template_name = "pedagogy/uv_edit.jinja"
def get_form_kwargs(self):
kwargs = super(UVCreateView, self).get_form_kwargs()
kwargs = super().get_form_kwargs()
kwargs["author_id"] = self.request.user.id
return kwargs
@ -328,7 +327,7 @@ class UVUpdateView(CanEditPropMixin, UpdateView):
template_name = "pedagogy/uv_edit.jinja"
def get_form_kwargs(self):
kwargs = super(UVUpdateView, self).get_form_kwargs()
kwargs = super().get_form_kwargs()
obj = self.get_object()
kwargs["author_id"] = obj.author.id
return kwargs