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

@ -32,7 +32,7 @@ class StudentCardForm(forms.ModelForm):
fields = ["uid"]
def clean(self):
cleaned_data = super(StudentCardForm, self).clean()
cleaned_data = super().clean()
uid = cleaned_data.get("uid", None)
if not uid or not StudentCard.is_valid(uid):
raise forms.ValidationError(_("This UID is invalid"), code="invalid")
@ -57,10 +57,10 @@ class GetUserForm(forms.Form):
def as_p(self):
self.fields["code"].widget.attrs["autofocus"] = True
return super(GetUserForm, self).as_p()
return super().as_p()
def clean(self):
cleaned_data = super(GetUserForm, self).clean()
cleaned_data = super().clean()
cus = None
if cleaned_data["code"] != "":
if len(cleaned_data["code"]) == StudentCard.UID_SIZE:
@ -141,14 +141,14 @@ class ProductEditForm(forms.ModelForm):
)
def __init__(self, *args, **kwargs):
super(ProductEditForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
if self.instance.id:
self.fields["counters"].initial = [
str(c.id) for c in self.instance.counters.all()
]
def save(self, *args, **kwargs):
ret = super(ProductEditForm, self).save(*args, **kwargs)
ret = super().save(*args, **kwargs)
if self.fields["counters"].initial:
for cid in self.fields["counters"].initial:
c = Counter.objects.filter(id=int(cid)).first()