Skip to content

Commit 153c22b

Browse files
committed
Merge branch 'main' into serializable
2 parents 73eea66 + 89c4786 commit 153c22b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1739
-754
lines changed

.pre-commit-config.yaml

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,36 @@ repos:
1414
hooks:
1515
- id: doc8
1616
- repo: https://github.com/adamchainz/django-upgrade
17-
rev: 1.22.2
17+
rev: 1.24.0
1818
hooks:
1919
- id: django-upgrade
2020
args: [--target-version, "4.2"]
21+
- repo: https://github.com/adamchainz/djade-pre-commit
22+
rev: "1.4.0"
23+
hooks:
24+
- id: djade
25+
args: [--target-version, "4.2"]
2126
- repo: https://github.com/pre-commit/pygrep-hooks
2227
rev: v1.10.0
2328
hooks:
2429
- id: rst-backticks
2530
- id: rst-directive-colons
26-
- repo: https://github.com/pre-commit/mirrors-prettier
27-
rev: v4.0.0-alpha.8
28-
hooks:
29-
- id: prettier
30-
entry: env PRETTIER_LEGACY_CLI=1 prettier
31-
types_or: [javascript, css]
32-
args:
33-
- --trailing-comma=es5
34-
- repo: https://github.com/pre-commit/mirrors-eslint
35-
rev: v9.19.0
36-
hooks:
37-
- id: eslint
38-
additional_dependencies:
39-
40-
- "@eslint/[email protected]"
41-
- "globals"
42-
files: \.js?$
43-
types: [file]
44-
args:
45-
- --fix
31+
- repo: https://github.com/biomejs/pre-commit
32+
rev: v2.0.0-beta.3
33+
hooks:
34+
- id: biome-check
35+
verbose: true
4636
- repo: https://github.com/astral-sh/ruff-pre-commit
47-
rev: 'v0.9.4'
37+
rev: 'v0.11.9'
4838
hooks:
4939
- id: ruff
5040
args: [--fix, --exit-non-zero-on-fix]
5141
- id: ruff-format
5242
- repo: https://github.com/tox-dev/pyproject-fmt
53-
rev: v2.5.0
43+
rev: v2.5.1
5444
hooks:
5545
- id: pyproject-fmt
5646
- repo: https://github.com/abravalheri/validate-pyproject
57-
rev: v0.23
47+
rev: v0.24.1
5848
hooks:
5949
- id: validate-pyproject

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
version: 2
66

77
build:
8-
os: ubuntu-22.04
8+
os: ubuntu-24.04
99
tools:
1010
python: "3.10"
1111

CONTRIBUTING.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
# Contributing to Django Debug Toolbar
2+
13
This is a [Django Commons](https://github.com/django-commons/) project. By contributing you agree to abide by the [Contributor Code of Conduct](https://github.com/django-commons/membership/blob/main/CODE_OF_CONDUCT.md).
24

3-
Please see the
4-
[README](https://github.com/django-commons/membership/blob/main/README.md)
5-
for more help.
5+
## Documentation
6+
7+
For detailed contributing guidelines, please see our [Documentation](https://django-debug-toolbar.readthedocs.io/en/latest/contributing.html).
8+
9+
## Additional Resources
10+
11+
Please see the [README](https://github.com/django-commons/membership/blob/main/README.md) for more help.

Makefile

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
.PHONY: example test coverage translatable_strings update_translations
1+
.PHONY: example test coverage translatable_strings update_translations help
2+
.DEFAULT_GOAL := help
23

3-
example:
4+
example: ## Run the example application
45
python example/manage.py migrate --noinput
56
-DJANGO_SUPERUSER_PASSWORD=p python example/manage.py createsuperuser \
67
--noinput --username="$(USER)" --email="$(USER)@mailinator.com"
@@ -12,34 +13,38 @@ example_async:
1213
--noinput --username="$(USER)" --email="$(USER)@mailinator.com"
1314
daphne example.asgi:application
1415

15-
example_test:
16+
example_test: ## Run the test suite for the example application
1617
python example/manage.py test example
1718

18-
test:
19+
test: ## Run the test suite
1920
DJANGO_SETTINGS_MODULE=tests.settings \
2021
python -m django test $${TEST_ARGS:-tests}
2122

22-
test_selenium:
23+
test_selenium: ## Run frontend tests written with Selenium
2324
DJANGO_SELENIUM_TESTS=true DJANGO_SETTINGS_MODULE=tests.settings \
2425
python -m django test $${TEST_ARGS:-tests}
2526

26-
coverage:
27+
coverage: ## Run the test suite with coverage enabled
2728
python --version
2829
DJANGO_SETTINGS_MODULE=tests.settings \
2930
python -b -W always -m coverage run -m django test -v2 $${TEST_ARGS:-tests}
3031
coverage report
3132
coverage html
3233
coverage xml
3334

34-
translatable_strings:
35+
translatable_strings: ## Update the English '.po' file
3536
cd debug_toolbar && python -m django makemessages -l en --no-obsolete
3637
@echo "Please commit changes and run 'tx push -s' (or wait for Transifex to pick them)"
3738

38-
update_translations:
39+
update_translations: ## Download updated '.po' files from Transifex
3940
tx pull -a --minimum-perc=10
4041
cd debug_toolbar && python -m django compilemessages
4142

4243
.PHONY: example/django-debug-toolbar.png
43-
example/django-debug-toolbar.png: example/screenshot.py
44+
example/django-debug-toolbar.png: example/screenshot.py ## Update the screenshot in 'README.rst'
4445
python $< --browser firefox --headless -o $@
4546
optipng $@
47+
48+
help: ## Help message for targets
49+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
50+
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Here's a screenshot of the toolbar in action:
4040
In addition to the built-in panels, a number of third-party panels are
4141
contributed by the community.
4242

43-
The current stable version of the Debug Toolbar is 5.0.1. It works on
43+
The current stable version of the Debug Toolbar is 5.2.0. It works on
4444
Django ≥ 4.2.0.
4545

4646
The Debug Toolbar has experimental support for `Django's asynchronous views

biome.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.0.0-beta.2/schema.json",
3+
"formatter": {
4+
"enabled": true,
5+
"useEditorconfig": true
6+
},
7+
"assist": {
8+
"actions": {
9+
"source": {
10+
"organizeImports": "on"
11+
}
12+
}
13+
},
14+
"linter": {
15+
"enabled": true,
16+
"rules": {
17+
"recommended": true,
18+
"style": {
19+
"useLiteralEnumMembers": "error",
20+
"noCommaOperator": "error",
21+
"useNodejsImportProtocol": "error",
22+
"useAsConstAssertion": "error",
23+
"useNumericLiterals": "error",
24+
"useEnumInitializers": "error",
25+
"useSelfClosingElements": "error",
26+
"useConst": "error",
27+
"useSingleVarDeclarator": "error",
28+
"noUnusedTemplateLiteral": "error",
29+
"useNumberNamespace": "error",
30+
"noInferrableTypes": "error",
31+
"useExponentiationOperator": "error",
32+
"useTemplate": "error",
33+
"noParameterAssign": "error",
34+
"noNonNullAssertion": "error",
35+
"useDefaultParameterLast": "error",
36+
"noArguments": "error",
37+
"useImportType": "error",
38+
"useExportType": "error",
39+
"noUselessElse": "error",
40+
"useShorthandFunctionType": "error"
41+
}
42+
}
43+
},
44+
"javascript": {
45+
"formatter": {
46+
"trailingCommas": "es5",
47+
"quoteStyle": "double"
48+
}
49+
}
50+
}

debug_toolbar/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# Do not use pkg_resources to find the version but set it here directly!
66
# see issue #1446
7-
VERSION = "5.0.1"
7+
VERSION = "5.2.0"
88

99
# Code that discovers files or modules in INSTALLED_APPS imports this module.
1010
urls = "debug_toolbar.urls", APP_NAME

debug_toolbar/decorators.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
11
import functools
22

3+
from asgiref.sync import iscoroutinefunction
34
from django.http import Http404
45
from django.utils.translation import get_language, override as language_override
56

67
from debug_toolbar import settings as dt_settings
78

89

910
def require_show_toolbar(view):
10-
@functools.wraps(view)
11-
def inner(request, *args, **kwargs):
12-
from debug_toolbar.middleware import get_show_toolbar
11+
"""
12+
Async compatible decorator to restrict access to a view
13+
based on the Debug Toolbar's visibility settings.
14+
"""
15+
from debug_toolbar.middleware import get_show_toolbar
16+
17+
if iscoroutinefunction(view):
1318

14-
show_toolbar = get_show_toolbar()
15-
if not show_toolbar(request):
16-
raise Http404
19+
@functools.wraps(view)
20+
async def inner(request, *args, **kwargs):
21+
show_toolbar = get_show_toolbar(async_mode=True)
22+
if not await show_toolbar(request):
23+
raise Http404
1724

18-
return view(request, *args, **kwargs)
25+
return await view(request, *args, **kwargs)
26+
else:
27+
28+
@functools.wraps(view)
29+
def inner(request, *args, **kwargs):
30+
show_toolbar = get_show_toolbar(async_mode=False)
31+
if not show_toolbar(request):
32+
raise Http404
33+
34+
return view(request, *args, **kwargs)
1935

2036
return inner
2137

2.74 KB
Binary file not shown.

0 commit comments

Comments
 (0)