Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pyupgrade's target version to Python 3.9 #2024

Merged
merged 3 commits into from
Oct 31, 2024
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 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
3 changes: 2 additions & 1 deletion debug_toolbar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ packages = [
path = "debug_toolbar/__init__.py"

[tool.ruff]
target-version = "py38"
target-version = "py39"

fix = true
show-fixes = true
Expand Down