From fabb3b5866b60375738e2e10b3fbb6d9e1d3def9 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Mon, 1 Dec 2025 09:55:15 +0300 Subject: [PATCH] Features: 1) Add type annotations in `validate` method of serializers for improved clarity. Fixes: 1) Correct type signature in `validate` method for serializers. Extra: 1) Remove redundant worker log format configurations in Celery; 2) Simplify log message format in log configuration for conciseness. --- engine/vibes_auth/serializers.py | 4 ++-- evibes/celery.py | 2 -- evibes/settings/logconfig.py | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/engine/vibes_auth/serializers.py b/engine/vibes_auth/serializers.py index a6743853..e849d65d 100644 --- a/engine/vibes_auth/serializers.py +++ b/engine/vibes_auth/serializers.py @@ -210,7 +210,7 @@ class TokenRefreshSerializer(Serializer): def validate(self, attrs: dict[str, Any]) -> dict[str, str]: refresh = self.token_class(attrs["refresh"]) - data = {"access": str(refresh.access_token)} + data: dict[str, str | dict[str, Any]] = {"access": str(refresh.access_token)} if api_settings.ROTATE_REFRESH_TOKENS: if api_settings.BLACKLIST_AFTER_ROTATION: @@ -241,7 +241,7 @@ class TokenVerifySerializer(Serializer): self.retrieve_user: bool = retrieve_user - def validate(self, attrs: dict[str, None]) -> dict[Any, Any]: + def validate(self, attrs: dict[str, Any]) -> dict[Any, Any]: token = UntypedToken(attrs["token"]) if ( diff --git a/evibes/celery.py b/evibes/celery.py index 5ddabb48..0c28594b 100644 --- a/evibes/celery.py +++ b/evibes/celery.py @@ -8,8 +8,6 @@ app = Celery("evibes") app.conf.update( worker_hijack_root_logger=False, - worker_log_format="[%(asctime)s: %(levelname)s/%(processName)s] %(name)s: %(message)s", - worker_task_log_format="[%(asctime)s: %(levelname)s/%(processName)s] %(name)s: %(message)s", broker_connection_retry_on_startup=True, task_serializer="json", result_serializer="json", diff --git a/evibes/settings/logconfig.py b/evibes/settings/logconfig.py index 2952f853..549916a7 100644 --- a/evibes/settings/logconfig.py +++ b/evibes/settings/logconfig.py @@ -21,7 +21,7 @@ LOGGING = { "formatters": { "color": { "()": "colorlog.ColoredFormatter", - "format": "%(asctime)s %(log_color)s[%(levelname)s]%(reset)s %(name)s:%(module)s:%(lineno)d: %(message)s", + "format": "%(asctime)s %(log_color)s[%(levelname)s]%(reset)s: %(message)s", "datefmt": "%Y-%m-%d %H:%M:%S", "log_colors": { "DEBUG": "cyan",