From 5da8ead2ff0091e92876b47d3a508985ac737808 Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Sat, 2 May 2026 11:14:02 +0200 Subject: [PATCH] fixed ruff in backend --- backend/api/management/commands/gc_orphan_images.py | 8 ++++---- backend/api/management/commands/sync_flavors.py | 4 +++- backend/api/models/user.py | 4 +--- backend/api/tests/test_auth.py | 8 ++------ backend/api/utils/cookie_auth.py | 2 -- backend/api/views/admin.py | 5 +---- 6 files changed, 11 insertions(+), 20 deletions(-) diff --git a/backend/api/management/commands/gc_orphan_images.py b/backend/api/management/commands/gc_orphan_images.py index d946bee..59e33a8 100644 --- a/backend/api/management/commands/gc_orphan_images.py +++ b/backend/api/management/commands/gc_orphan_images.py @@ -42,9 +42,7 @@ class Command(BaseCommand): referenced_dirs: set[str] = set() legacy_image_files: set[str] = set() - for flavor in Flavor.objects.all().only( - "local_image_paths", "main_image_path", "image" - ): + for flavor in Flavor.objects.all().only("local_image_paths", "main_image_path", "image"): paths = list(flavor.local_image_paths or []) if flavor.main_image_path: paths.append(flavor.main_image_path) @@ -86,7 +84,9 @@ class Command(BaseCommand): entry.unlink() verb = "Would delete" if dry_run else "Deleted" - self.stdout.write(self.style.SUCCESS(f"{verb}: {len(deleted_dirs)} dirs, {len(deleted_files)} files")) + self.stdout.write( + self.style.SUCCESS(f"{verb}: {len(deleted_dirs)} dirs, {len(deleted_files)} files") + ) for path in deleted_dirs: self.stdout.write(f" dir {path}") for path in deleted_files: diff --git a/backend/api/management/commands/sync_flavors.py b/backend/api/management/commands/sync_flavors.py index b122c50..bff8879 100644 --- a/backend/api/management/commands/sync_flavors.py +++ b/backend/api/management/commands/sync_flavors.py @@ -71,7 +71,9 @@ class Command(BaseCommand): results: dict[int, str] = {} with ThreadPoolExecutor(max_workers=_DOWNLOAD_WORKERS) as ex: - futures = {ex.submit(self.download_image_to_path, url, rel): i for i, url, rel in targets} + futures = { + ex.submit(self.download_image_to_path, url, rel): i for i, url, rel in targets + } for fut, i in futures.items(): saved = fut.result() if saved: diff --git a/backend/api/models/user.py b/backend/api/models/user.py index 3a04548..f722496 100644 --- a/backend/api/models/user.py +++ b/backend/api/models/user.py @@ -32,9 +32,7 @@ class User(AbstractUser): ] theme = models.CharField(max_length=20, choices=THEME_CHOICES, default="holy_light") language = models.CharField(max_length=2, choices=LANGUAGE_CHOICES, default="en") - drawer_anchor = models.CharField( - max_length=5, choices=DRAWER_ANCHOR_CHOICES, default="left" - ) + drawer_anchor = models.CharField(max_length=5, choices=DRAWER_ANCHOR_CHOICES, default="left") avatar = models.ImageField(upload_to="avatars/", blank=True, null=True) pending_email = models.EmailField(max_length=254, blank=True, null=True) email_confirmation_code = models.CharField(max_length=6, blank=True, null=True) diff --git a/backend/api/tests/test_auth.py b/backend/api/tests/test_auth.py index a4a0c14..0d1373d 100644 --- a/backend/api/tests/test_auth.py +++ b/backend/api/tests/test_auth.py @@ -56,9 +56,5 @@ class JWTAuthTests(APITestCase): response = self.client.post(reverse("auth_logout"), format="json") self.assertEqual(response.status_code, status.HTTP_200_OK) # set-cookie should be present with empty/expired value to clear them. - self.assertEqual( - response.cookies[settings.JWT_AUTH_COOKIE_ACCESS].value, "" - ) - self.assertEqual( - response.cookies[settings.JWT_AUTH_COOKIE_REFRESH].value, "" - ) + self.assertEqual(response.cookies[settings.JWT_AUTH_COOKIE_ACCESS].value, "") + self.assertEqual(response.cookies[settings.JWT_AUTH_COOKIE_REFRESH].value, "") diff --git a/backend/api/utils/cookie_auth.py b/backend/api/utils/cookie_auth.py index f2ecf68..1f2aab0 100644 --- a/backend/api/utils/cookie_auth.py +++ b/backend/api/utils/cookie_auth.py @@ -35,8 +35,6 @@ class CookieJWTScheme(OpenApiAuthenticationExtension): } - - def set_jwt_cookies(response, access: str | None, refresh: str | None) -> None: """Attach access/refresh tokens to the response as httpOnly cookies.""" from datetime import timedelta diff --git a/backend/api/views/admin.py b/backend/api/views/admin.py index eceedea..b38233a 100644 --- a/backend/api/views/admin.py +++ b/backend/api/views/admin.py @@ -160,10 +160,7 @@ class AdminViewSet(viewsets.ViewSet): try: send_mail( "Holy Flavors Admin Test Email", - ( - f"This is a test email sent to {me.email} from the " - f"Holy Flavors Admin Interface." - ), + (f"This is a test email sent to {me.email} from the Holy Flavors Admin Interface."), settings.DEFAULT_FROM_EMAIL, [me.email], fail_silently=False,