Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ repos:
- id: prettier
types_or: [javascript, css]
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.7.0
rev: v8.9.0
hooks:
- id: eslint
files: \.js?$
types: [file]
args:
- --fix
- repo: https://github.com/psf/black
rev: 21.12b0
rev: 22.1.0
hooks:
- id: black
language_version: python3
Expand Down
26 changes: 10 additions & 16 deletions debug_toolbar/panels/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,26 +236,20 @@ def _store_call_info(
@property
def nav_subtitle(self):
cache_calls = len(self.calls)
return (
ngettext(
"%(cache_calls)d call in %(time).2fms",
"%(cache_calls)d calls in %(time).2fms",
cache_calls,
)
% {"cache_calls": cache_calls, "time": self.total_time}
)
return ngettext(
"%(cache_calls)d call in %(time).2fms",
"%(cache_calls)d calls in %(time).2fms",
cache_calls,
) % {"cache_calls": cache_calls, "time": self.total_time}

@property
def title(self):
count = len(getattr(settings, "CACHES", ["default"]))
return (
ngettext(
"Cache calls from %(count)d backend",
"Cache calls from %(count)d backends",
count,
)
% {"count": count}
)
return ngettext(
"Cache calls from %(count)d backend",
"Cache calls from %(count)d backends",
count,
) % {"count": count}

def enable_instrumentation(self):
for alias in cache.caches:
Expand Down
24 changes: 9 additions & 15 deletions debug_toolbar/panels/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,16 @@ def nav_subtitle(self):
# here we have to handle a double count translation, hence the
# hard coding of one signal
if num_signals == 1:
return (
ngettext(
"%(num_receivers)d receiver of 1 signal",
"%(num_receivers)d receivers of 1 signal",
num_receivers,
)
% {"num_receivers": num_receivers}
)
return (
ngettext(
"%(num_receivers)d receiver of %(num_signals)d signals",
"%(num_receivers)d receivers of %(num_signals)d signals",
return ngettext(
"%(num_receivers)d receiver of 1 signal",
"%(num_receivers)d receivers of 1 signal",
num_receivers,
)
% {"num_receivers": num_receivers, "num_signals": num_signals}
)
) % {"num_receivers": num_receivers}
return ngettext(
"%(num_receivers)d receiver of %(num_signals)d signals",
"%(num_receivers)d receivers of %(num_signals)d signals",
num_receivers,
) % {"num_receivers": num_receivers, "num_signals": num_signals}

title = _("Signals")

Expand Down
13 changes: 5 additions & 8 deletions debug_toolbar/panels/sql/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,11 @@ def nav_subtitle(self):
@property
def title(self):
count = len(self._databases)
return (
ngettext(
"SQL queries from %(count)d connection",
"SQL queries from %(count)d connections",
count,
)
% {"count": count}
)
return ngettext(
"SQL queries from %(count)d connection",
"SQL queries from %(count)d connections",
count,
) % {"count": count}

template = "debug_toolbar/panels/sql.html"

Expand Down
2 changes: 1 addition & 1 deletion debug_toolbar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def getframeinfo(frame, context=1):
for line in first_lines[:2]:
# File coding may be specified. Match pattern from PEP-263
# (https://www.python.org/dev/peps/pep-0263/)
match = re.search(br"coding[:=]\s*([-\w.]+)", line)
match = re.search(rb"coding[:=]\s*([-\w.]+)", line)
if match:
encoding = match.group(1).decode("ascii")
break
Expand Down