Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Apply "replace @functools.lru_cache(maxsize=None) with shorthand" fix…
  • Loading branch information
ulgens committed Oct 30, 2024
commit 2ce9e92760d73a2fc6698160e2223df8db02ab07
4 changes: 2 additions & 2 deletions debug_toolbar/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import re
import socket
from functools import lru_cache
from functools import cache

from asgiref.sync import iscoroutinefunction, markcoroutinefunction
from django.conf import settings
Expand Down Expand Up @@ -46,7 +46,7 @@ def show_toolbar(request):
return False


@lru_cache(maxsize=None)
@cache
def get_show_toolbar():
# If SHOW_TOOLBAR_CALLBACK is a string, which is the recommended
# setup, resolve it to the corresponding callable.
Expand Down
4 changes: 2 additions & 2 deletions debug_toolbar/panels/sql/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from functools import lru_cache
from functools import cache, lru_cache
from html import escape

import sqlparse
Expand Down Expand Up @@ -107,7 +107,7 @@ def parse_sql(sql, *, simplify=False):
return "".join(stack.run(sql))


@lru_cache(maxsize=None)
@cache
def get_filter_stack(*, simplify):
stack = sqlparse.engine.FilterStack()
if simplify:
Expand Down
6 changes: 3 additions & 3 deletions debug_toolbar/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import warnings
from functools import lru_cache
from functools import cache

from django.conf import settings
from django.dispatch import receiver
Expand Down Expand Up @@ -49,7 +49,7 @@
}


@lru_cache(maxsize=None)
@cache
def get_config():
USER_CONFIG = getattr(settings, "DEBUG_TOOLBAR_CONFIG", {})
CONFIG = CONFIG_DEFAULTS.copy()
Expand All @@ -75,7 +75,7 @@ def get_config():
]


@lru_cache(maxsize=None)
@cache
def get_panels():
try:
PANELS = list(settings.DEBUG_TOOLBAR_PANELS)
Expand Down
4 changes: 2 additions & 2 deletions debug_toolbar/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re
import uuid
from collections import OrderedDict
from functools import lru_cache
from functools import cache

from django.apps import apps
from django.conf import settings
Expand Down Expand Up @@ -180,7 +180,7 @@ def is_toolbar_request(cls, request):
return resolver_match.namespaces and resolver_match.namespaces[-1] == APP_NAME

@staticmethod
@lru_cache(maxsize=None)
@cache
def get_observe_request():
# If OBSERVE_REQUEST_CALLBACK is a string, which is the recommended
# setup, resolve it to the corresponding callable.
Expand Down