Skip to content

Commit 3895446

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 39d5ea5 commit 3895446

File tree

11 files changed

+20
-20
lines changed

11 files changed

+20
-20
lines changed

debug_toolbar/management/commands/debugsqlshell.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def execute(self, sql, params=()):
2828
end_time = time()
2929
duration = (end_time - start_time) * 1000
3030
formatted_sql = sqlparse.format(raw_sql, reindent=True)
31-
print("{} [{:.2f}ms]".format(formatted_sql, duration))
31+
print(f"{formatted_sql} [{duration:.2f}ms]")
3232

3333

3434
base_module.CursorDebugWrapper = PrintQueryWrapper

debug_toolbar/panels/cache.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def __init__(self, cache):
6969
self.cache = cache
7070

7171
def __repr__(self):
72-
return str("<CacheStatTracker for %s>") % repr(self.cache)
72+
return "<CacheStatTracker for %s>" % repr(self.cache)
7373

7474
def _get_func_info(self):
7575
frame = sys._getframe(3)

debug_toolbar/panels/profiling.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def parent_classes(self):
3030

3131
def background(self):
3232
r, g, b = hsv_to_rgb(*self.hsv)
33-
return "rgb({:f}%,{:f}%,{:f}%)".format(r * 100, g * 100, b * 100)
33+
return f"rgb({r * 100:f}%,{g * 100:f}%,{b * 100:f}%)"
3434

3535
def func_std_string(self): # match what old profile produced
3636
func_name = self.func

debug_toolbar/panels/signals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def generate_stats(self, request, response):
9797
receiver_class_name = getattr(
9898
receiver.__self__, "__class__", type
9999
).__name__
100-
text = "{}.{}".format(receiver_class_name, receiver_name)
100+
text = f"{receiver_class_name}.{receiver_name}"
101101
else:
102102
text = receiver_name
103103
receivers.append(text)

debug_toolbar/panels/sql/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def reformat_sql(sql, with_toggle=False):
2626
if not with_toggle:
2727
return formatted
2828
simple = simplify(parse_sql(sql, aligned_indent=False))
29-
uncollapsed = '<span class="djDebugUncollapsed">{}</span>'.format(simple)
30-
collapsed = '<span class="djDebugCollapsed djdt-hidden">{}</span>'.format(formatted)
29+
uncollapsed = f'<span class="djDebugUncollapsed">{simple}</span>'
30+
collapsed = f'<span class="djDebugCollapsed djdt-hidden">{formatted}</span>'
3131
return collapsed + uncollapsed
3232

3333

debug_toolbar/panels/sql/views.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ def sql_explain(request, verified_data):
4949
# SQLite's EXPLAIN dumps the low-level opcodes generated for a query;
5050
# EXPLAIN QUERY PLAN dumps a more human-readable summary
5151
# See https://www.sqlite.org/lang_explain.html for details
52-
cursor.execute("EXPLAIN QUERY PLAN {}".format(sql), params)
52+
cursor.execute(f"EXPLAIN QUERY PLAN {sql}", params)
5353
elif vendor == "postgresql":
54-
cursor.execute("EXPLAIN ANALYZE {}".format(sql), params)
54+
cursor.execute(f"EXPLAIN ANALYZE {sql}", params)
5555
else:
56-
cursor.execute("EXPLAIN {}".format(sql), params)
56+
cursor.execute(f"EXPLAIN {sql}", params)
5757
headers = [d[0] for d in cursor.description]
5858
result = cursor.fetchall()
5959

debug_toolbar/panels/templates/panel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def _request_context_bind_template(self, template):
4242
self.context_processors = OrderedDict()
4343
updates = {}
4444
for processor in processors:
45-
name = "{}.{}".format(processor.__module__, processor.__name__)
45+
name = f"{processor.__module__}.{processor.__name__}"
4646
context = processor(self.request)
4747
self.context_processors[name] = context
4848
updates.update(context)

debug_toolbar/panels/templates/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def template_source(request):
4444
except TemplateDoesNotExist:
4545
pass
4646
else:
47-
source = "Template Does Not Exist: {}".format(template_origin_name)
47+
source = f"Template Does Not Exist: {template_origin_name}"
4848

4949
try:
5050
from pygments import highlight

debug_toolbar/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def get_module_path(module_name):
2727
try:
2828
module = import_module(module_name)
2929
except ImportError as e:
30-
raise ImproperlyConfigured("Error importing HIDE_IN_STACKTRACES: {}".format(e))
30+
raise ImproperlyConfigured(f"Error importing HIDE_IN_STACKTRACES: {e}")
3131
else:
3232
source_path = inspect.getsourcefile(module)
3333
if source_path.endswith("__init__.py"):
@@ -157,7 +157,7 @@ def get_name_from_obj(obj):
157157

158158
if hasattr(obj, "__module__"):
159159
module = obj.__module__
160-
name = "{}.{}".format(module, name)
160+
name = f"{module}.{name}"
161161

162162
return name
163163

tests/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Binary(models.Model):
1515
from django.db.models import JSONField
1616
except ImportError: # Django<3.1
1717
try:
18-
from django.contrib.postgres.fields import JSONField
18+
from django.db.models import JSONField
1919
except ImportError: # psycopg2 not installed
2020
JSONField = None
2121

tests/panels/test_sql.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@ def test_param_conversion(self):
145145
and not (django.VERSION >= (4, 1) and connection.vendor == "mysql")
146146
):
147147
self.assertEqual(
148-
tuple([q[1]["params"] for q in self.panel._queries]),
148+
tuple(q[1]["params"] for q in self.panel._queries),
149149
('["Foo"]', "[10, 1]", '["2017-12-22 16:07:01"]'),
150150
)
151151
else:
152152
self.assertEqual(
153-
tuple([q[1]["params"] for q in self.panel._queries]),
153+
tuple(q[1]["params"] for q in self.panel._queries),
154154
('["Foo", true, false]', "[10, 1]", '["2017-12-22 16:07:01"]'),
155155
)
156156

@@ -244,7 +244,7 @@ def test_raw_query_param_conversion(self):
244244
self.assertEqual(len(self.panel._queries), 2)
245245

246246
self.assertEqual(
247-
tuple([q[1]["params"] for q in self.panel._queries]),
247+
tuple(q[1]["params"] for q in self.panel._queries),
248248
(
249249
'["Foo", true, false, "2017-12-22 16:07:01"]',
250250
" ".join(
@@ -263,7 +263,7 @@ def test_insert_content(self):
263263
Test that the panel only inserts content after generate_stats and
264264
not the process_request.
265265
"""
266-
list(User.objects.filter(username="café".encode("utf-8")))
266+
list(User.objects.filter(username="café".encode()))
267267
response = self.panel.process_request(self.request)
268268
# ensure the panel does not have content yet.
269269
self.assertNotIn("café", self.panel.content)
@@ -279,7 +279,7 @@ def test_insert_locals(self):
279279
Test that the panel inserts locals() content.
280280
"""
281281
local_var = "<script>alert('test');</script>" # noqa: F841
282-
list(User.objects.filter(username="café".encode("utf-8")))
282+
list(User.objects.filter(username="café".encode()))
283283
response = self.panel.process_request(self.request)
284284
self.panel.generate_stats(self.request, response)
285285
self.assertIn("local_var", self.panel.content)
@@ -293,7 +293,7 @@ def test_not_insert_locals(self):
293293
"""
294294
Test that the panel does not insert locals() content.
295295
"""
296-
list(User.objects.filter(username="café".encode("utf-8")))
296+
list(User.objects.filter(username="café".encode()))
297297
response = self.panel.process_request(self.request)
298298
self.panel.generate_stats(self.request, response)
299299
self.assertNotIn("djdt-locals", self.panel.content)

0 commit comments

Comments
 (0)