diff --git a/promgen/migrations/0023_shard_authorization.py b/promgen/migrations/0023_shard_authorization.py index 7087383ca..aa04753cf 100644 --- a/promgen/migrations/0023_shard_authorization.py +++ b/promgen/migrations/0023_shard_authorization.py @@ -1,6 +1,5 @@ # Generated by Django 4.2.11 on 2024-06-28 09:57 -import django.core.validators from django.db import migrations, models diff --git a/promgen/urls.py b/promgen/urls.py index f1c1f6dd0..3f1ebc0ee 100644 --- a/promgen/urls.py +++ b/promgen/urls.py @@ -16,7 +16,6 @@ 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ -from django.urls import path from django.contrib import admin from django.urls import include, path from django.views.decorators.csrf import csrf_exempt diff --git a/promgen/util.py b/promgen/util.py index 7e754f05e..135e9ed73 100644 --- a/promgen/util.py +++ b/promgen/util.py @@ -79,7 +79,7 @@ def setting(key, default=None, domain=None): try: rtn = rtn[index] except KeyError: - if default != KeyError: + if default is not KeyError: return default raise KeyError(f"Missing required setting: {key}") return rtn @@ -121,6 +121,7 @@ def wrapped(field): return wrapped + def proxy_error(response: requests.Response) -> HttpResponse: """ Return a wrapped proxy error diff --git a/promgen/views.py b/promgen/views.py index f92262587..33a24eec5 100644 --- a/promgen/views.py +++ b/promgen/views.py @@ -11,8 +11,6 @@ from itertools import chain import prometheus_client -from prometheus_client.parser import text_string_to_metric_families - import requests from django.conf import settings from django.contrib import messages @@ -30,6 +28,7 @@ from django.views.generic.detail import SingleObjectMixin from django.views.generic.edit import CreateView, DeleteView, FormView from prometheus_client.core import CounterMetricFamily, GaugeMetricFamily +from prometheus_client.parser import text_string_to_metric_families from requests.exceptions import HTTPError import promgen.templatetags.promgen as macro @@ -309,8 +308,8 @@ def post(self, request, pk): request, "Removed filter {} {}".format( self.escape_square_brackets(f.name), - self.escape_square_brackets(f.value) - ) + self.escape_square_brackets(f.value), + ), ) if "filter.name" in request.POST: obj = self.get_object() @@ -322,16 +321,16 @@ def post(self, request, pk): request, "Created filter {} {}".format( self.escape_square_brackets(f.name), - self.escape_square_brackets(f.value) - ) + self.escape_square_brackets(f.value), + ), ) else: messages.warning( request, "Updated filter {} {}".format( self.escape_square_brackets(f.name), - self.escape_square_brackets(f.value) - ) + self.escape_square_brackets(f.value), + ), ) if "next" in request.POST: return redirect(request.POST["next"])