From 9be1a0c8c3fcf9ddb9a45680b068aceaac6203b5 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Tue, 14 May 2024 13:46:17 +0200 Subject: [PATCH] style: format ruff --- backend/core/base_models.py | 6 ++--- backend/core/forms.py | 48 ++++++++++++++++++------------------- backend/iam/forms.py | 36 ++++++++++++++-------------- backend/serdes/views.py | 6 ++--- 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/backend/core/base_models.py b/backend/core/base_models.py index 40487af17..aae66186f 100644 --- a/backend/core/base_models.py +++ b/backend/core/base_models.py @@ -90,9 +90,9 @@ def clean(self) -> None: if not self.is_unique_in_scope(scope=scope, fields_to_check=_fields_to_check): for field in _fields_to_check: if not self.is_unique_in_scope(scope=scope, fields_to_check=[field]): - field_errors[ - field - ] = f"{getattr(self, field)} is already used in this scope. Please choose another value." + field_errors[field] = ( + f"{getattr(self, field)} is already used in this scope. Please choose another value." + ) super().clean() if field_errors: raise ValidationError(field_errors) diff --git a/backend/core/forms.py b/backend/core/forms.py index 220cf4daf..3c9ba9736 100644 --- a/backend/core/forms.py +++ b/backend/core/forms.py @@ -80,9 +80,9 @@ def __init__(self, recommended_reference_controls=None, *args, **kwargs) -> None def get_context(self, name, value, attrs): context = super().get_context(name, value, attrs) if self.recommended_reference_controls: - context[ - "recommended_reference_controls" - ] = self.recommended_reference_controls + context["recommended_reference_controls"] = ( + self.recommended_reference_controls + ) return context @@ -127,31 +127,31 @@ def __init__(self, *args, **kwargs): f.widget.attrs["id"] = ( f"id_{model_name}_{fname}" if model_name else f"id_{fname}" ) - f.widget.attrs[ - "class" - ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + f.widget.attrs["class"] = ( + "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + ) if input_type in select_inputs: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs[ - "autocomplete" - ] = "off" # workaround for Firefox behavior: https://stackoverflow.com/questions/4831848/firefox-ignores-option-selected-selected - f.widget.attrs[ - "class" - ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 disabled:opacity-50" + f.widget.attrs["autocomplete"] = ( + "off" # workaround for Firefox behavior: https://stackoverflow.com/questions/4831848/firefox-ignores-option-selected-selected + ) + f.widget.attrs["class"] = ( + "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 disabled:opacity-50" + ) if input_type == Textarea: - f.widget.attrs[ - "class" - ] = "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500" + f.widget.attrs["class"] = ( + "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500" + ) if input_type == CheckboxInput: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs[ - "class" - ] = "w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500" + f.widget.attrs["class"] = ( + "w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500" + ) if input_type == DefaultDateInput: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs[ - "class" - ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + f.widget.attrs["class"] = ( + "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + ) if input_type == Select: self.default_if_one(fname) @@ -181,9 +181,9 @@ def __init__(self, *args, **kwargs): super(__class__, self).__init__(*args, **kwargs) for password in self.fields.items(): password[1].widget.attrs["class"] = style - self.fields["terms_service"].widget.attrs[ - "class" - ] = "ml-2 rounded border-gray-300 shadow-sm focus:border-indigo-600 focus:ring focus:ring-indigo-500 focus:ring-opacity-50 text-indigo-500" + self.fields["terms_service"].widget.attrs["class"] = ( + "ml-2 rounded border-gray-300 shadow-sm focus:border-indigo-600 focus:ring focus:ring-indigo-500 focus:ring-opacity-50 text-indigo-500" + ) self.fields["terms_service"].widget.attrs["id"] = "terms_service" terms_service = forms.BooleanField(label=_("terms and conditions of use")) diff --git a/backend/iam/forms.py b/backend/iam/forms.py index ada57867c..448875e6c 100644 --- a/backend/iam/forms.py +++ b/backend/iam/forms.py @@ -61,28 +61,28 @@ def __init__(self, *args, **kwargs): f.widget.attrs["id"] = ( f"id_{model_name}_{fname}" if model_name else f"id_{fname}" ) - f.widget.attrs[ - "class" - ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + f.widget.attrs["class"] = ( + "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + ) if input_type in select_inputs: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs[ - "class" - ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + f.widget.attrs["class"] = ( + "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + ) if input_type == Textarea: - f.widget.attrs[ - "class" - ] = "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500" + f.widget.attrs["class"] = ( + "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500" + ) if input_type == CheckboxInput: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs[ - "class" - ] = "w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500" + f.widget.attrs["class"] = ( + "w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500" + ) if input_type == DefaultDateInput: f.widget.attrs["id"] = f"id_{model_name}_{fname}" - f.widget.attrs[ - "class" - ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + f.widget.attrs["class"] = ( + "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + ) class FolderUpdateForm(StyledModelForm): @@ -238,9 +238,9 @@ class UserPasswordChangeForm(AdminPasswordChangeForm): def __init__(self, user, *args, **kwargs): super().__init__(user, *args, **kwargs) for fname, f in self.fields.items(): - f.widget.attrs[ - "class" - ] = "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + f.widget.attrs["class"] = ( + "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" + ) print("FNAME:", fname) self.fields.get("password1").widget.attrs["id"] = "password1" self.fields.get("password2").widget.attrs["id"] = "password2" diff --git a/backend/serdes/views.py b/backend/serdes/views.py index 3ceed8bf5..4cd2cb218 100644 --- a/backend/serdes/views.py +++ b/backend/serdes/views.py @@ -21,9 +21,9 @@ def get(self, request, *args, **kwargs): return Response(status=status.HTTP_403_FORBIDDEN) response = HttpResponse(content_type="application/json") timestamp = datetime.now().strftime("%Y%m%d-%H%M%S") - response[ - "Content-Disposition" - ] = f'attachment; filename="ciso-assistant-db-{timestamp}.json"' + response["Content-Disposition"] = ( + f'attachment; filename="ciso-assistant-db-{timestamp}.json"' + ) response.write(f'[{{"meta": [{{"media_version": "{VERSION}"}}]}},\n') # Here we dump th data to stdout