Skip to content

Commit f17396f

Browse files
committed
Add pyupgrade to ruff config
1 parent cc84559 commit f17396f

File tree

6 files changed

+9
-6
lines changed

6 files changed

+9
-6
lines changed

django_prometheus/exports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def SetupPrometheusEndpointOnPortRange(port_range, addr=""):
9191
thread = PrometheusEndpointServer(httpd)
9292
thread.daemon = True
9393
thread.start()
94-
logger.info("Exporting Prometheus /metrics/ on port %s" % port)
94+
logger.info(f"Exporting Prometheus /metrics/ on port {port}")
9595
return port # Stop trying ports at this point
9696
logger.warning("Cannot export Prometheus /metrics/ - no available ports in supplied range")
9797
return None

django_prometheus/tests/end2end/testapp/test_middleware.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ def M(metric_name):
1414
This is just intended to help keep the lines shorter in test
1515
cases.
1616
"""
17-
return "django_http_%s" % metric_name
17+
return f"django_http_{metric_name}"
1818

1919

2020
def T(metric_name):
2121
"""Makes a full metric name from a short metric name like M(metric_name)
2222
2323
This method adds a '_total' postfix for metrics."""
24-
return "%s_total" % M(metric_name)
24+
return f"{M(metric_name)}_total"
2525

2626

2727
class TestMiddlewareMetrics:

django_prometheus/tests/end2end/testapp/test_migrations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def M(metric_name):
1212
This is just intended to help keep the lines shorter in test
1313
cases.
1414
"""
15-
return "django_migrations_%s" % metric_name
15+
return f"django_migrations_{metric_name}"
1616

1717

1818
@pytest.mark.django_db()

django_prometheus/tests/end2end/testapp/test_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def M(metric_name):
1010
This is just intended to help keep the lines shorter in test
1111
cases.
1212
"""
13-
return "django_model_%s" % metric_name
13+
return f"django_model_{metric_name}"
1414

1515

1616
@pytest.mark.django_db()

django_prometheus/testutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def format_labels(labels):
189189
Out:
190190
'{method="GET",port="80"}'
191191
"""
192-
return "{%s}" % ",".join([f'{k}="{v}"' for k, v in labels.items()])
192+
return "{{{}}}".format(",".join([f'{k}="{v}"' for k, v in labels.items()]))
193193

194194

195195
def format_vector(vector):

ruff.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ select = [
2121
# https://docs.astral.sh/ruff/rules/#flake8-debugger-t10
2222
# https://github.com/jbkahn/flake8-debugger
2323
"T10",
24+
# https://docs.astral.sh/ruff/rules/#pyupgrade-up
25+
# https://github.com/asottile/pyupgrade
26+
"UP",
2427
# https://docs.astral.sh/ruff/rules/#flake8-2020-ytt
2528
# https://github.com/asottile-archive/flake8-2020
2629
"YTT",

0 commit comments

Comments
 (0)