Skip to content

Commit ab1602e

Browse files
authored
Merge branch 'django-commons:main' into copy-context
2 parents 21e65d7 + 2401406 commit ab1602e

32 files changed

+922
-462
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
name: python-package-distributions
4949
path: dist/
5050
- name: Publish distribution 📦 to PyPI
51-
uses: pypa/gh-action-pypi-publish@release/v1.10
51+
uses: pypa/gh-action-pypi-publish@release/v1.12
5252

5353
github-release:
5454
name: >-
@@ -69,7 +69,7 @@ jobs:
6969
name: python-package-distributions
7070
path: dist/
7171
- name: Sign the dists with Sigstore
72-
uses: sigstore/gh-action-sigstore-python@v3
72+
uses: sigstore/gh-action-sigstore-python@v3.0.0
7373
with:
7474
inputs: >-
7575
./dist/*.tar.gz
@@ -95,7 +95,7 @@ jobs:
9595
9696
publish-to-testpypi:
9797
name: Publish Python 🐍 distribution 📦 to TestPyPI
98-
if: startsWith(github.ref, 'refs/tags/') # only publish to TestPyPI on tag pushes
98+
if: startsWith(github.ref, 'refs/tags/') # only publish to Test PyPI on tag pushes
9999
needs:
100100
- build
101101
runs-on: ubuntu-latest
@@ -114,7 +114,7 @@ jobs:
114114
name: python-package-distributions
115115
path: dist/
116116
- name: Publish distribution 📦 to TestPyPI
117-
uses: pypa/gh-action-pypi-publish@release/v1.10
117+
uses: pypa/gh-action-pypi-publish@release/v1.12
118118
with:
119119
repository-url: https://test.pypi.org/legacy/
120120
skip-existing: true

.pre-commit-config.yaml

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repos:
1414
hooks:
1515
- id: doc8
1616
- repo: https://github.com/adamchainz/django-upgrade
17-
rev: 1.22.2
17+
rev: 1.23.1
1818
hooks:
1919
- id: django-upgrade
2020
args: [--target-version, "4.2"]
@@ -23,34 +23,19 @@ repos:
2323
hooks:
2424
- id: rst-backticks
2525
- 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.17.0
36-
hooks:
37-
- id: eslint
38-
additional_dependencies:
39-
- "eslint@v9.17.0"
40-
- "@eslint/js@v9.17.0"
41-
- "globals"
42-
files: \.js?$
43-
types: [file]
44-
args:
45-
- --fix
26+
- repo: https://github.com/biomejs/pre-commit
27+
rev: v1.9.4
28+
hooks:
29+
- id: biome-check
30+
verbose: true
4631
- repo: https://github.com/astral-sh/ruff-pre-commit
47-
rev: 'v0.8.4'
32+
rev: 'v0.9.10'
4833
hooks:
4934
- id: ruff
5035
args: [--fix, --exit-non-zero-on-fix]
5136
- id: ruff-format
5237
- repo: https://github.com/tox-dev/pyproject-fmt
53-
rev: v2.5.0
38+
rev: v2.5.1
5439
hooks:
5540
- id: pyproject-fmt
5641
- repo: https://github.com/abravalheri/validate-pyproject

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,39 +1,44 @@
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"
78
python example/manage.py runserver
89

9-
example_test:
10+
example_test: ## Run the test suite for the example application
1011
python example/manage.py test example
1112

12-
test:
13+
test: ## Run the test suite
1314
DJANGO_SETTINGS_MODULE=tests.settings \
1415
python -m django test $${TEST_ARGS:-tests}
1516

16-
test_selenium:
17+
test_selenium: ## Run frontend tests written with Selenium
1718
DJANGO_SELENIUM_TESTS=true DJANGO_SETTINGS_MODULE=tests.settings \
1819
python -m django test $${TEST_ARGS:-tests}
1920

20-
coverage:
21+
coverage: ## Run the test suite with coverage enabled
2122
python --version
2223
DJANGO_SETTINGS_MODULE=tests.settings \
2324
python -b -W always -m coverage run -m django test -v2 $${TEST_ARGS:-tests}
2425
coverage report
2526
coverage html
2627
coverage xml
2728

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

32-
update_translations:
33+
update_translations: ## Download updated '.po' files from Transifex
3334
tx pull -a --minimum-perc=10
3435
cd debug_toolbar && python -m django compilemessages
3536

3637
.PHONY: example/django-debug-toolbar.png
37-
example/django-debug-toolbar.png: example/screenshot.py
38+
example/django-debug-toolbar.png: example/screenshot.py ## Update the screenshot in 'README.rst'
3839
python $< --browser firefox --headless -o $@
3940
optipng $@
41+
42+
help: ## Help message for targets
43+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
44+
| 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.0-alpha. It works on
43+
The current stable version of the Debug Toolbar is 5.0.1. 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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3+
"formatter": {
4+
"enabled": true,
5+
"useEditorconfig": true
6+
},
7+
"organizeImports": {
8+
"enabled": true
9+
},
10+
"linter": {
11+
"enabled": true,
12+
"rules": {
13+
"recommended": true
14+
}
15+
},
16+
"javascript": {
17+
"formatter": {
18+
"trailingCommas": "es5",
19+
"quoteStyle": "double"
20+
}
21+
}
22+
}

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.0-alpha"
7+
VERSION = "5.0.1"
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)