diff --git a/docker/gunicorn.py b/docker/gunicorn.py index ca4b67fe..7c76d82c 100644 --- a/docker/gunicorn.py +++ b/docker/gunicorn.py @@ -1,5 +1,7 @@ import json +import gunicorn + accesslog = "-" errorlog = "-" access_log_format = json.dumps( @@ -27,6 +29,4 @@ chdir = "/app" # Obfuscate the Server header (to the md5sum of "Springload") -import gunicorn - gunicorn.SERVER_SOFTWARE = "04e96149a2f64d6135c82d199ab62122" diff --git a/ietf/blog/models.py b/ietf/blog/models.py index 67fafe00..d5cb757b 100644 --- a/ietf/blog/models.py +++ b/ietf/blog/models.py @@ -298,7 +298,7 @@ def serve(self, request, *args, **kwargs): try: topic_id = int(topic_id) except ValueError: - raise Http404 + raise Http404 from None filter_topic = get_object_or_404(Topic, id=topic_id) query_string_segments = [] for parameter, _function in parameter_functions_map.items(): diff --git a/ietf/forms/models.py b/ietf/forms/models.py index d8ac5075..98aed430 100644 --- a/ietf/forms/models.py +++ b/ietf/forms/models.py @@ -33,7 +33,7 @@ def send_mail(self, form): super().send_mail(form) except Exception as ex: logger.error(f"Failed to send email with exception: {ex}") - raise EmailException + raise EmailException from ex def serve(self, request, *args, **kwargs): try: @@ -42,7 +42,7 @@ def serve(self, request, *args, **kwargs): messages.add_message( request, messages.ERROR, message="Failed to send email" ) - raise EmailException + raise FormPage.content_panels = [ diff --git a/ietf/settings/dev.py b/ietf/settings/dev.py index 817442aa..b593a467 100644 --- a/ietf/settings/dev.py +++ b/ietf/settings/dev.py @@ -1,4 +1,6 @@ -from .base import * +import contextlib + +from .base import * # noqa: F403 # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -15,7 +17,5 @@ CELERY_EAGER_PROPAGATES_EXCEPTIONS = True CELERY_ALWAYS_EAGER = True -try: # pragma: no cover - from .local import * -except ImportError: # pragma: no cover - pass +with contextlib.suppress(ImportError): + from .local import * # noqa: F403 diff --git a/ietf/settings/docker/__init__.py b/ietf/settings/docker/__init__.py index f835ce9b..4e665532 100644 --- a/ietf/settings/docker/__init__.py +++ b/ietf/settings/docker/__init__.py @@ -5,7 +5,7 @@ StringVariable, ) -from ..base import * +from ..base import * # noqa: F403 _ENVVARS = [ StringVariable( @@ -31,4 +31,4 @@ FillVars(_ENVVARS, vars()) FillVars(_DJANGO_ENVVARS, vars(), "DJANGO_") -ALLOWED_HOSTS = ADDRESSES +ALLOWED_HOSTS = ADDRESSES # noqa: F405 diff --git a/ietf/settings/docker/base.py b/ietf/settings/docker/base.py index c9059d3c..9cde3a0b 100644 --- a/ietf/settings/docker/base.py +++ b/ietf/settings/docker/base.py @@ -1,3 +1,3 @@ -from . import * -from .grains.database import * -from .grains.logging import * +from . import * # noqa: F403 +from .grains.database import * # noqa: F403 +from .grains.logging import * # noqa: F403 diff --git a/ietf/settings/docker/dev.py b/ietf/settings/docker/dev.py index 99684588..8923e8be 100644 --- a/ietf/settings/docker/dev.py +++ b/ietf/settings/docker/dev.py @@ -1,4 +1,4 @@ -from .base import * +from .base import * # noqa: F403 DEBUG = True CACHE_MIDDLEWARE_ALIAS = "dummy" diff --git a/ietf/settings/production.py b/ietf/settings/production.py index bcb86499..84ff4736 100644 --- a/ietf/settings/production.py +++ b/ietf/settings/production.py @@ -1,6 +1,7 @@ +import contextlib import os -from .base import * +from .base import * # noqa: F403 # Do not set SECRET_KEY, Postgres or LDAP password or any other sensitive data here. # Instead, create a local.py file on the server. @@ -40,7 +41,7 @@ SERVER_EMAIL = env["SERVER_EMAIL"] if "CACHE_PURGE_URL" in env: - INSTALLED_APPS += ("wagtail.contrib.frontend_cache",) + INSTALLED_APPS += ("wagtail.contrib.frontend_cache",) # noqa: F405 WAGTAILFRONTENDCACHE = { "default": { "BACKEND": "wagtail.contrib.frontend_cache.backends.HTTPBackend", @@ -75,10 +76,10 @@ # Caches if "CACHE_DEFAULT" in env: - CACHES["default"]["LOCATION"] = env.get("CACHE_DEFAULT") + CACHES["default"]["LOCATION"] = env.get("CACHE_DEFAULT") # noqa: F405 if "CACHE_SESSIONS" in env: - CACHES["sessions"]["LOCATION"] = env.get("CACHE_SESSIONS") + CACHES["sessions"]["LOCATION"] = env.get("CACHE_SESSIONS") # noqa: F405 # Logging @@ -119,7 +120,5 @@ LOGGING["loggers"]["django.request"]["handlers"].append("errors_file") LOGGING["loggers"]["django.security"]["handlers"].append("errors_file") -try: - from .local import * # pyflakes:ignore -except ImportError: - pass +with contextlib.suppress(ImportError): + from .local import * # noqa: F403