Skip to content

Commit

Permalink
Fix remaining ruff issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mgax committed Jun 19, 2024
1 parent e036a52 commit 4786269
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 24 deletions.
4 changes: 2 additions & 2 deletions docker/gunicorn.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import json

import gunicorn

accesslog = "-"
errorlog = "-"
access_log_format = json.dumps(
Expand Down Expand Up @@ -27,6 +29,4 @@
chdir = "/app"

# Obfuscate the Server header (to the md5sum of "Springload")
import gunicorn

gunicorn.SERVER_SOFTWARE = "04e96149a2f64d6135c82d199ab62122"
2 changes: 1 addition & 1 deletion ietf/blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
4 changes: 2 additions & 2 deletions ietf/forms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 = [
Expand Down
10 changes: 5 additions & 5 deletions ietf/settings/dev.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions ietf/settings/docker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
StringVariable,
)

from ..base import *
from ..base import * # noqa: F403

_ENVVARS = [
StringVariable(
Expand All @@ -31,4 +31,4 @@

FillVars(_ENVVARS, vars())
FillVars(_DJANGO_ENVVARS, vars(), "DJANGO_")
ALLOWED_HOSTS = ADDRESSES
ALLOWED_HOSTS = ADDRESSES # noqa: F405
6 changes: 3 additions & 3 deletions ietf/settings/docker/base.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion ietf/settings/docker/dev.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .base import *
from .base import * # noqa: F403

DEBUG = True
CACHE_MIDDLEWARE_ALIAS = "dummy"
15 changes: 7 additions & 8 deletions ietf/settings/production.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 4786269

Please sign in to comment.