diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py index 1bf9b4e70..9986d9106 100644 --- a/debug_toolbar/middleware.py +++ b/debug_toolbar/middleware.py @@ -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 @@ -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. diff --git a/debug_toolbar/panels/sql/utils.py b/debug_toolbar/panels/sql/utils.py index b8fd34afe..305543aec 100644 --- a/debug_toolbar/panels/sql/utils.py +++ b/debug_toolbar/panels/sql/utils.py @@ -1,4 +1,4 @@ -from functools import lru_cache +from functools import cache, lru_cache from html import escape import sqlparse @@ -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: diff --git a/debug_toolbar/settings.py b/debug_toolbar/settings.py index 48483cf40..e0be35ea8 100644 --- a/debug_toolbar/settings.py +++ b/debug_toolbar/settings.py @@ -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 @@ -49,7 +49,7 @@ } -@lru_cache(maxsize=None) +@cache def get_config(): USER_CONFIG = getattr(settings, "DEBUG_TOOLBAR_CONFIG", {}) CONFIG = CONFIG_DEFAULTS.copy() @@ -75,7 +75,7 @@ def get_config(): ] -@lru_cache(maxsize=None) +@cache def get_panels(): try: PANELS = list(settings.DEBUG_TOOLBAR_PANELS) diff --git a/debug_toolbar/toolbar.py b/debug_toolbar/toolbar.py index edd5c369b..afb7affac 100644 --- a/debug_toolbar/toolbar.py +++ b/debug_toolbar/toolbar.py @@ -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 @@ -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. diff --git a/debug_toolbar/utils.py b/debug_toolbar/utils.py index 26154a736..dc3cc1adc 100644 --- a/debug_toolbar/utils.py +++ b/debug_toolbar/utils.py @@ -5,8 +5,9 @@ import os.path import sys import warnings +from collections.abc import Sequence from pprint import PrettyPrinter, pformat -from typing import Any, Sequence +from typing import Any from asgiref.local import Local from django.http import QueryDict diff --git a/pyproject.toml b/pyproject.toml index 637fc0a16..32c78c93a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,7 @@ packages = [ path = "debug_toolbar/__init__.py" [tool.ruff] -target-version = "py38" +target-version = "py39" fix = true show-fixes = true