diff --git a/evibes/middleware.py b/evibes/middleware.py index 17149504..56e21545 100644 --- a/evibes/middleware.py +++ b/evibes/middleware.py @@ -16,7 +16,7 @@ from sentry_sdk import capture_exception from evibes.settings import DEBUG -logger = logging.getLogger("evibes") +logger = logging.getLogger("django.request") class CustomCommonMiddleware(CommonMiddleware): diff --git a/evibes/settings/database.py b/evibes/settings/database.py index cdbe49f3..80a8858f 100644 --- a/evibes/settings/database.py +++ b/evibes/settings/database.py @@ -1,4 +1,4 @@ -from evibes.settings.base import getenv +from os import getenv DATABASES = { "default": { diff --git a/evibes/settings/dbbackup.py b/evibes/settings/dbbackup.py index fa86b908..2b788def 100644 --- a/evibes/settings/dbbackup.py +++ b/evibes/settings/dbbackup.py @@ -1,4 +1,4 @@ -from evibes.settings.base import getenv +from os import getenv DBBACKUP_CONNECTORS = { "default": { diff --git a/evibes/settings/drf.py b/evibes/settings/drf.py index 393acec0..6522e244 100644 --- a/evibes/settings/drf.py +++ b/evibes/settings/drf.py @@ -1,9 +1,9 @@ -# mypy: ignore-errors from datetime import timedelta +from os import getenv from django.utils.translation import gettext_lazy as _ -from evibes.settings.base import * # noqa: F403 +from evibes.settings import DEBUG, EVIBES_VERSION, SECRET_KEY from evibes.settings.constance import CONSTANCE_CONFIG REST_FRAMEWORK: dict = { diff --git a/evibes/settings/elasticsearch.py b/evibes/settings/elasticsearch.py index 171208e3..257262a3 100644 --- a/evibes/settings/elasticsearch.py +++ b/evibes/settings/elasticsearch.py @@ -1,9 +1,11 @@ -from evibes.settings.base import * # noqa: F403 +from os import getenv + +from evibes.settings import DEBUG ELASTICSEARCH_DSL = { "default": { "hosts": ["http://elasticsearch:9200"], - "http_auth": ("elastic", getenv("ELASTIC_PASSWORD")), # noqa: F405 + "http_auth": ("elastic", getenv("ELASTIC_PASSWORD")), "verify_certs": False, "timeout": 30, "ssl_show_warn": False, @@ -12,6 +14,6 @@ ELASTICSEARCH_DSL = { }, } -ELASTICSEARCH_DSL_AUTOSYNC = DEBUG # noqa: F405 +ELASTICSEARCH_DSL_AUTOSYNC = DEBUG ELASTICSEARCH_DSL_PARALLEL = True ELASTICSEARCH_DSL_SIGNAL_PROCESSOR = "django_elasticsearch_dsl.signals.CelerySignalProcessor" diff --git a/evibes/settings/extensions.py b/evibes/settings/extensions.py index a46ad2d7..9d3cff60 100644 --- a/evibes/settings/extensions.py +++ b/evibes/settings/extensions.py @@ -1,3 +1,5 @@ +from evibes.settings.base import * # noqa: F403 + GRAPH_MODELS = { "all_applications": True, "group_models": True, diff --git a/evibes/settings/graphene.py b/evibes/settings/graphene.py index 376a410c..e46bd3e7 100644 --- a/evibes/settings/graphene.py +++ b/evibes/settings/graphene.py @@ -1,11 +1,11 @@ -from evibes.settings.base import * # noqa: F403 +from evibes.settings.base import DEBUG GRAPHENE = { "MIDDLEWARE": [ "evibes.middleware.GrapheneLoggingErrorsDebugMiddleware", "evibes.middleware.GrapheneJWTAuthorizationMiddleware", ] - if DEBUG # noqa: F405 + if DEBUG else [ "evibes.middleware.GrapheneJWTAuthorizationMiddleware", ], diff --git a/evibes/settings/logconfig.py b/evibes/settings/logconfig.py index 375d7f6c..bdce7eb8 100644 --- a/evibes/settings/logconfig.py +++ b/evibes/settings/logconfig.py @@ -1,8 +1,10 @@ -from evibes.settings.base import * # noqa: F403 +import logging + +from evibes.settings.base import DEBUG -class SkipVariableDoesNotExistFilter(logging.Filter): # noqa: F405 - def filter(self, record: logging.LogRecord) -> bool: # noqa: F405 +class SkipVariableDoesNotExistFilter(logging.Filter): + def filter(self, record: logging.LogRecord) -> bool: if record.exc_info: exc_type, exc_instance, _ = record.exc_info try: @@ -57,57 +59,69 @@ LOGGING = { "class": "logging.StreamHandler", "formatter": "color", }, - "mail_admins": { - "level": "ERROR", - "class": "django.utils.log.AdminEmailHandler", - "include_html": True, - "formatter": "plain", - }, }, "loggers": { "django": { - "handlers": ["console_debug", "console_production"], + "handlers": [ + "console_debug" if DEBUG else "console_production", + ], "level": "DEBUG" if DEBUG else "INFO", # noqa: F405 "propagate": True, }, "django.request": { - "handlers": ["console_debug", "mail_admins"], - "level": "DEBUG" if DEBUG else "INFO", # noqa: F405 + "handlers": [ + "console_debug" if DEBUG else "console_production", + ], + "level": "DEBUG" if DEBUG else "INFO", "propagate": False, }, "django.db.backends": { - "handlers": ["console_debug" if DEBUG else "console_production"], # noqa: F405 + "handlers": [ + "console_debug" if DEBUG else "console_production", + ], "level": "WARNING", "propagate": False, }, "django.template": { - "handlers": ["console_debug", "console_production"], - "level": "DEBUG" if DEBUG else "INFO", # noqa: F405 + "handlers": [ + "console_debug" if DEBUG else "console_production", + ], + "level": "DEBUG" if DEBUG else "INFO", "propagate": True, "filters": ["skip_variable_doesnotexist"], }, "evibes": { - "handlers": ["console_debug" if DEBUG else "console_production"], # noqa: F405 - "level": "DEBUG" if DEBUG else "WARNING", # noqa: F405 + "handlers": [ + "console_debug" if DEBUG else "console_production", + ], + "level": "DEBUG" if DEBUG else "WARNING", "propagate": True, }, "django_elasticsearch_dsl": { - "handlers": ["console_debug" if DEBUG else "console_production"], # noqa: F405 + "handlers": [ + "console_debug" if DEBUG else "console_production", + ], "level": "WARNING", "propagate": False, }, "celery.app.trace": { - "handlers": ["console_debug" if DEBUG else "console_production"], # noqa: F405 - "level": "DEBUG" if DEBUG else "INFO", # noqa: F405 + "handlers": [ + "console_debug" if DEBUG else "console_production", + ], + "level": "DEBUG" if DEBUG else "INFO", "propagate": False, }, "celery.worker.strategy": { - "handlers": ["console_debug" if DEBUG else "console_production"], # noqa: F405 - "level": "DEBUG" if DEBUG else "INFO", # noqa: F405 + "handlers": [ + "console_debug" if DEBUG else "console_production", + ], + "level": "DEBUG" if DEBUG else "INFO", "propagate": False, }, "elastic_transport.transport": { - "handlers": ["console_debug" if DEBUG else "console_production"], # noqa: F405 + "handlers": [ + "console_debug" if DEBUG else "console_production", + ], "level": "ERROR", "propagate": False, },