Skip to content

Commit 2ce9e92

Browse files
committed
Apply "replace @functools.lru_cache(maxsize=None) with shorthand" fixes from pyupgrade
https://github.com/asottile/pyupgrade?tab=readme-ov-file#replace-functoolslru_cachemaxsizenone-with-shorthand
1 parent 89f824a commit 2ce9e92

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

debug_toolbar/middleware.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import re
66
import socket
7-
from functools import lru_cache
7+
from functools import cache
88

99
from asgiref.sync import iscoroutinefunction, markcoroutinefunction
1010
from django.conf import settings
@@ -46,7 +46,7 @@ def show_toolbar(request):
4646
return False
4747

4848

49-
@lru_cache(maxsize=None)
49+
@cache
5050
def get_show_toolbar():
5151
# If SHOW_TOOLBAR_CALLBACK is a string, which is the recommended
5252
# setup, resolve it to the corresponding callable.

debug_toolbar/panels/sql/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from functools import lru_cache
1+
from functools import cache, lru_cache
22
from html import escape
33

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

109109

110-
@lru_cache(maxsize=None)
110+
@cache
111111
def get_filter_stack(*, simplify):
112112
stack = sqlparse.engine.FilterStack()
113113
if simplify:

debug_toolbar/settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
import warnings
3-
from functools import lru_cache
3+
from functools import cache
44

55
from django.conf import settings
66
from django.dispatch import receiver
@@ -49,7 +49,7 @@
4949
}
5050

5151

52-
@lru_cache(maxsize=None)
52+
@cache
5353
def get_config():
5454
USER_CONFIG = getattr(settings, "DEBUG_TOOLBAR_CONFIG", {})
5555
CONFIG = CONFIG_DEFAULTS.copy()
@@ -75,7 +75,7 @@ def get_config():
7575
]
7676

7777

78-
@lru_cache(maxsize=None)
78+
@cache
7979
def get_panels():
8080
try:
8181
PANELS = list(settings.DEBUG_TOOLBAR_PANELS)

debug_toolbar/toolbar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import re
66
import uuid
77
from collections import OrderedDict
8-
from functools import lru_cache
8+
from functools import cache
99

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

182182
@staticmethod
183-
@lru_cache(maxsize=None)
183+
@cache
184184
def get_observe_request():
185185
# If OBSERVE_REQUEST_CALLBACK is a string, which is the recommended
186186
# setup, resolve it to the corresponding callable.

0 commit comments

Comments
 (0)