Skip to content

Commit fc4bf66

Browse files
authored
Update pyupgrade's target version to Python 3.9 (#2024)
* Update ruff's Python target-version value to 3.9 We no longer support Python 3.8 * Apply "import replacements" fixes from pyupgrade https://github.com/asottile/pyupgrade?tab=readme-ov-file#import-replacements * 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 396b626 commit fc4bf66

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

debug_toolbar/middleware.py

+2-2
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

+2-2
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

+3-3
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

+2-2
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.

debug_toolbar/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
import os.path
66
import sys
77
import warnings
8+
from collections.abc import Sequence
89
from pprint import PrettyPrinter, pformat
9-
from typing import Any, Sequence
10+
from typing import Any
1011

1112
from asgiref.local import Local
1213
from django.http import QueryDict

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ packages = [
5151
path = "debug_toolbar/__init__.py"
5252

5353
[tool.ruff]
54-
target-version = "py38"
54+
target-version = "py39"
5555

5656
fix = true
5757
show-fixes = true

0 commit comments

Comments
 (0)