From b041e7cbe4c19f87d96edd7804ab1fd042826f9f Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Mon, 5 Feb 2024 17:30:40 +0000
Subject: [PATCH 001/200] [pre-commit.ci] pre-commit autoupdate
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
updates:
- [github.com/pre-commit/mirrors-eslint: v8.56.0 → v9.0.0-alpha.2](https://github.com/pre-commit/mirrors-eslint/compare/v8.56.0...v9.0.0-alpha.2)
- [github.com/astral-sh/ruff-pre-commit: v0.1.11 → v0.2.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.11...v0.2.0)
- [github.com/tox-dev/pyproject-fmt: 1.5.3 → 1.7.0](https://github.com/tox-dev/pyproject-fmt/compare/1.5.3...1.7.0)
- [github.com/abravalheri/validate-pyproject: v0.15 → v0.16](https://github.com/abravalheri/validate-pyproject/compare/v0.15...v0.16)
---
.pre-commit-config.yaml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index c2f93ac73..f2dea2dd0 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -40,16 +40,16 @@ repos:
args:
- --fix
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: 'v0.1.11'
+ rev: 'v0.2.0'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/tox-dev/pyproject-fmt
- rev: 1.5.3
+ rev: 1.7.0
hooks:
- id: pyproject-fmt
- repo: https://github.com/abravalheri/validate-pyproject
- rev: v0.15
+ rev: v0.16
hooks:
- id: validate-pyproject
From 6591d021c8c363d26d4d6ae6d9afa59181443945 Mon Sep 17 00:00:00 2001
From: Matthias Kestenholz
Date: Mon, 5 Feb 2024 19:08:13 +0100
Subject: [PATCH 002/200] Make ruff complain less
---
debug_toolbar/panels/profiling.py | 6 ++----
pyproject.toml | 14 ++++++++------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/debug_toolbar/panels/profiling.py b/debug_toolbar/panels/profiling.py
index 2b7742400..64224a2db 100644
--- a/debug_toolbar/panels/profiling.py
+++ b/debug_toolbar/panels/profiling.py
@@ -86,12 +86,10 @@ def func_std_string(self): # match what old profile produced
)
def subfuncs(self):
- i = 0
h, s, v = self.hsv
count = len(self.statobj.all_callees[self.func])
- for func, stats in self.statobj.all_callees[self.func].items():
- i += 1
- h1 = h + (i / count) / (self.depth + 1)
+ for i, (func, stats) in enumerate(self.statobj.all_callees[self.func].items()):
+ h1 = h + ((i + 1) / count) / (self.depth + 1)
s1 = 0 if stats[3] == 0 else s * (stats[3] / self.stats[3])
yield FunctionCall(
self.statobj,
diff --git a/pyproject.toml b/pyproject.toml
index e529808cb..944543d91 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -51,6 +51,11 @@ packages = ["debug_toolbar"]
path = "debug_toolbar/__init__.py"
[tool.ruff]
+fix = true
+show-fixes = true
+target-version = "py38"
+
+[tool.ruff.lint]
extend-select = [
"ASYNC", # flake8-async
"B", # flake8-bugbear
@@ -75,17 +80,14 @@ extend-ignore = [
"E501", # Ignore line length violations
"SIM108", # Use ternary operator instead of if-else-block
]
-fix = true
-show-fixes = true
-target-version = "py38"
-[tool.ruff.isort]
+[tool.ruff.lint.isort]
combine-as-imports = true
-[tool.ruff.mccabe]
+[tool.ruff.lint.mccabe]
max-complexity = 16
-[tool.ruff.per-file-ignores]
+[tool.ruff.lint.per-file-ignores]
"*/migrat*/*" = [
"N806", # Allow using PascalCase model names in migrations
"N999", # Ignore the fact that migration files are invalid module names
From 757b82e4c71676ecd9db5aa7b0ab3206644eb37c Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Tue, 6 Feb 2024 08:51:09 +0100
Subject: [PATCH 003/200] [pre-commit.ci] pre-commit autoupdate (#1867)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Matthias Kestenholz
Co-authored-by: Christian Clauss
---
.pre-commit-config.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index f2dea2dd0..23d879f71 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -40,7 +40,7 @@ repos:
args:
- --fix
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: 'v0.2.0'
+ rev: 'v0.2.1'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
From c688ce4ad7d18c5ecb800869298ca8cf6c08be1d Mon Sep 17 00:00:00 2001
From: Tim Schilling
Date: Sun, 11 Feb 2024 09:55:32 -0600
Subject: [PATCH 004/200] Use url template tag for example URLs (#1879)
---
example/templates/index.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/example/templates/index.html b/example/templates/index.html
index 382bfb0e9..ee00d5f05 100644
--- a/example/templates/index.html
+++ b/example/templates/index.html
@@ -12,8 +12,8 @@ Index of Tests
jQuery 3.3.1
MooTools 1.6.0
Prototype 1.7.3.0
- Hotwire Turbo
- htmx
+ Hotwire Turbo
+ htmx
Django Admin
{% endcache %}
From 64697a4cdc7987a31bbc41d8f6802627f64c58c4 Mon Sep 17 00:00:00 2001
From: Christian Clauss
Date: Tue, 13 Feb 2024 13:56:49 +0100
Subject: [PATCH 005/200] Keep GitHub Actions up to date with GitHub's
Dependabot (#1876)
Autogenerates pull requests like #1660
* https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
* https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
---
.github/dependabot.yml | 13 +++++++++++++
1 file changed, 13 insertions(+)
create mode 100644 .github/dependabot.yml
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 000000000..be006de9a
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,13 @@
+# Keep GitHub Actions up to date with GitHub's Dependabot...
+# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
+# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
+version: 2
+updates:
+ - package-ecosystem: github-actions
+ directory: /
+ groups:
+ github-actions:
+ patterns:
+ - "*" # Group all Actions updates into a single larger pull request
+ schedule:
+ interval: weekly
From 14fbaa83b698d02a9bdb5b55575288f45015df4f Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Wed, 14 Feb 2024 09:35:56 +0100
Subject: [PATCH 006/200] Bump the github-actions group with 4 updates (#1885)
* Bump the github-actions group with 4 updates
Bumps the github-actions group with 4 updates: [actions/setup-python](https://github.com/actions/setup-python), [actions/cache](https://github.com/actions/cache), [actions/upload-artifact](https://github.com/actions/upload-artifact) and [actions/download-artifact](https://github.com/actions/download-artifact).
Updates `actions/setup-python` from 4 to 5
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4...v5)
Updates `actions/cache` from 3 to 4
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3...v4)
Updates `actions/upload-artifact` from 3 to 4
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3...v4)
Updates `actions/download-artifact` from 3 to 4
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v3...v4)
---
updated-dependencies:
- dependency-name: actions/setup-python
dependency-type: direct:production
update-type: version-update:semver-major
dependency-group: github-actions
- dependency-name: actions/cache
dependency-type: direct:production
update-type: version-update:semver-major
dependency-group: github-actions
- dependency-name: actions/upload-artifact
dependency-type: direct:production
update-type: version-update:semver-major
dependency-group: github-actions
- dependency-name: actions/download-artifact
dependency-type: direct:production
update-type: version-update:semver-major
dependency-group: github-actions
...
Signed-off-by: dependabot[bot]
* Attempt fixing the upload-artifact name collisions
---------
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Matthias Kestenholz
---
.github/workflows/release.yml | 2 +-
.github/workflows/test.yml | 37 ++++++++++++++++++-----------------
2 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 2059d37f8..b57181444 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -16,7 +16,7 @@ jobs:
fetch-depth: 0
- name: Set up Python
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v5
with:
python-version: 3.8
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index cb28e217e..72b40d010 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -33,7 +33,7 @@ jobs:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
@@ -44,7 +44,7 @@ jobs:
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
@@ -67,9 +67,9 @@ jobs:
DB_PORT: 3306
- name: Upload coverage data
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
- name: coverage-data
+ name: coverage-data-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.arch }}-mysql
path: ".coverage.*"
postgres:
@@ -108,7 +108,7 @@ jobs:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
@@ -119,7 +119,7 @@ jobs:
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
@@ -145,9 +145,9 @@ jobs:
DB_PORT: 5432
- name: Upload coverage data
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
- name: coverage-data
+ name: coverage-data-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.database }}
path: ".coverage.*"
sqlite:
@@ -162,7 +162,7 @@ jobs:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
@@ -173,7 +173,7 @@ jobs:
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
@@ -193,9 +193,9 @@ jobs:
DB_NAME: ":memory:"
- name: Upload coverage data
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
- name: coverage-data
+ name: coverage-data-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.arch }}-sqlite
path: ".coverage.*"
coverage:
@@ -204,7 +204,7 @@ jobs:
needs: [sqlite, mysql, postgres]
steps:
- uses: actions/checkout@v4
- - uses: actions/setup-python@v4
+ - uses: actions/setup-python@v5
with:
# Use latest, so it understands all syntax.
python-version: "3.11"
@@ -212,9 +212,10 @@ jobs:
- run: python -m pip install --upgrade coverage[toml]
- name: Download coverage data.
- uses: actions/download-artifact@v3
+ uses: actions/download-artifact@v4
with:
- name: coverage-data
+ pattern: coverage-data-*
+ merge-multiple: true
- name: Combine coverage & check percentage
run: |
@@ -223,7 +224,7 @@ jobs:
python -m coverage report
- name: Upload HTML report if check failed.
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: html-report
path: htmlcov
@@ -238,7 +239,7 @@ jobs:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v5
with:
python-version: 3.8
@@ -248,7 +249,7 @@ jobs:
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
From 38d2eea5f8b57f70a4b5bdebd6bdeae8c395d822 Mon Sep 17 00:00:00 2001
From: Elijah Okello
Date: Wed, 14 Feb 2024 11:37:21 +0300
Subject: [PATCH 007/200] #1870 fix pre commit errors (#1884)
* fix: fix for precommit errors
* fix: migrated .eslintrc.js to eslint.config.js flat config
* fix: added dependencies and added support for globals in eslint.config.js
* fix: set ecmaVersion to latest
---
.eslintrc.js | 22 ----------------------
.pre-commit-config.yaml | 8 ++++++--
eslint.config.js | 28 ++++++++++++++++++++++++++++
3 files changed, 34 insertions(+), 24 deletions(-)
delete mode 100644 .eslintrc.js
create mode 100644 eslint.config.js
diff --git a/.eslintrc.js b/.eslintrc.js
deleted file mode 100644
index b0c799d88..000000000
--- a/.eslintrc.js
+++ /dev/null
@@ -1,22 +0,0 @@
-module.exports = {
- root: true,
- "env": {
- "browser": true,
- "es6": true,
- node: true,
- },
- "extends": "eslint:recommended",
- "parserOptions": {
- "ecmaVersion": 6,
- "sourceType": "module"
- },
- "rules": {
- "curly": ["error", "all"],
- "dot-notation": "error",
- "eqeqeq": "error",
- "no-eval": "error",
- "no-var": "error",
- "prefer-const": "error",
- "semi": "error"
- }
-};
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 23d879f71..116a58560 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -14,7 +14,7 @@ repos:
hooks:
- id: doc8
- repo: https://github.com/adamchainz/django-upgrade
- rev: 1.15.0
+ rev: 1.16.0
hooks:
- id: django-upgrade
args: [--target-version, "3.2"]
@@ -32,9 +32,13 @@ repos:
args:
- --trailing-comma=es5
- repo: https://github.com/pre-commit/mirrors-eslint
- rev: v8.56.0
+ rev: v9.0.0-beta.0
hooks:
- id: eslint
+ additional_dependencies:
+ - "eslint@v9.0.0-beta.0"
+ - "@eslint/js@v9.0.0-beta.0"
+ - "globals"
files: \.js?$
types: [file]
args:
diff --git a/eslint.config.js b/eslint.config.js
new file mode 100644
index 000000000..0b4d0e49e
--- /dev/null
+++ b/eslint.config.js
@@ -0,0 +1,28 @@
+const js = require("@eslint/js");
+const globals = require("globals");
+
+module.exports = [
+ js.configs.recommended,
+ {
+ files: ["**/*.js"],
+ languageOptions:{
+ ecmaVersion: "latest",
+ sourceType: "module",
+ globals: {
+ ...globals.browser,
+ ...globals.node
+ }
+ }
+ },
+ {
+ rules: {
+ "curly": ["error", "all"],
+ "dot-notation": "error",
+ "eqeqeq": "error",
+ "no-eval": "error",
+ "no-var": "error",
+ "prefer-const": "error",
+ "semi": "error"
+ }
+ }
+];
From 0663276eb9e1dbfaf993733aef2005de20faa951 Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Thu, 22 Feb 2024 20:42:14 +0100
Subject: [PATCH 008/200] [pre-commit.ci] pre-commit autoupdate (#1888)
---
.pre-commit-config.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 116a58560..3876810d1 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -44,7 +44,7 @@ repos:
args:
- --fix
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: 'v0.2.1'
+ rev: 'v0.2.2'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
From 7d77a34dcd00bcbc1561541877be132bef1789a5 Mon Sep 17 00:00:00 2001
From: Tim Schilling
Date: Thu, 22 Feb 2024 13:42:50 -0600
Subject: [PATCH 009/200] Show toolbar for docker's internal IP address (#1887)
Fixes #1854
---
debug_toolbar/middleware.py | 18 +++++++++++++++++-
docs/changes.rst | 3 +++
docs/installation.rst | 10 ++++------
tests/test_integration.py | 9 +++++++++
4 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py
index b5e5d0827..38cf92884 100644
--- a/debug_toolbar/middleware.py
+++ b/debug_toolbar/middleware.py
@@ -3,6 +3,7 @@
"""
import re
+import socket
from functools import lru_cache
from django.conf import settings
@@ -19,7 +20,22 @@ def show_toolbar(request):
"""
Default function to determine whether to show the toolbar on a given page.
"""
- return settings.DEBUG and request.META.get("REMOTE_ADDR") in settings.INTERNAL_IPS
+ internal_ips = settings.INTERNAL_IPS.copy()
+
+ try:
+ # This is a hack for docker installations. It attempts to look
+ # up the IP address of the docker host.
+ # This is not guaranteed to work.
+ docker_ip = (
+ # Convert the last segment of the IP address to be .1
+ ".".join(socket.gethostbyname("host.docker.internal").rsplit(".")[:-1])
+ + ".1"
+ )
+ internal_ips.append(docker_ip)
+ except socket.gaierror:
+ # It's fine if the lookup errored since they may not be using docker
+ pass
+ return settings.DEBUG and request.META.get("REMOTE_ADDR") in internal_ips
@lru_cache(maxsize=None)
diff --git a/docs/changes.rst b/docs/changes.rst
index e2a610991..3caa35419 100644
--- a/docs/changes.rst
+++ b/docs/changes.rst
@@ -4,6 +4,9 @@ Change log
Pending
-------
+* Automatically support Docker rather than having the developer write a
+ workaround for ``INTERNAL_IPS``.
+
4.3.0 (2024-02-01)
------------------
diff --git a/docs/installation.rst b/docs/installation.rst
index a350d9c3a..1f2e1f119 100644
--- a/docs/installation.rst
+++ b/docs/installation.rst
@@ -145,12 +145,10 @@ option.
.. warning::
- If using Docker the following will set your ``INTERNAL_IPS`` correctly in Debug mode::
-
- if DEBUG:
- import socket # only if you haven't already imported this
- hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
- INTERNAL_IPS = [ip[: ip.rfind(".")] + ".1" for ip in ips] + ["127.0.0.1", "10.0.2.2"]
+ If using Docker, the toolbar will attempt to look up your host name
+ automatically and treat it as an allowable internal IP. If you're not
+ able to get the toolbar to work with your docker installation, review
+ the code in ``debug_toolbar.middleware.show_toolbar``.
Troubleshooting
---------------
diff --git a/tests/test_integration.py b/tests/test_integration.py
index 379fafaf4..4cfc84a78 100644
--- a/tests/test_integration.py
+++ b/tests/test_integration.py
@@ -2,6 +2,7 @@
import re
import time
import unittest
+from unittest.mock import patch
import html5lib
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
@@ -66,6 +67,14 @@ def test_show_toolbar_INTERNAL_IPS(self):
with self.settings(INTERNAL_IPS=[]):
self.assertFalse(show_toolbar(self.request))
+ @patch("socket.gethostbyname", return_value="127.0.0.255")
+ def test_show_toolbar_docker(self, mocked_gethostbyname):
+ with self.settings(INTERNAL_IPS=[]):
+ # Is true because REMOTE_ADDR is 127.0.0.1 and the 255
+ # is shifted to be 1.
+ self.assertTrue(show_toolbar(self.request))
+ mocked_gethostbyname.assert_called_once_with("host.docker.internal")
+
def test_should_render_panels_RENDER_PANELS(self):
"""
The toolbar should force rendering panels on each request
From e80c05df3425554a2cae1db064fc07e445b61a79 Mon Sep 17 00:00:00 2001
From: Matthias Kestenholz
Date: Thu, 22 Feb 2024 20:43:21 +0100
Subject: [PATCH 010/200] Raise the minimum Django version to 4.2 (#1880)
---
.pre-commit-config.yaml | 2 +-
README.rst | 4 ++--
docs/changes.rst | 1 +
pyproject.toml | 4 +---
tests/test_integration.py | 36 ++++++++++++++++++++++++------------
tox.ini | 16 ++++++----------
6 files changed, 35 insertions(+), 28 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 3876810d1..608371cea 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -17,7 +17,7 @@ repos:
rev: 1.16.0
hooks:
- id: django-upgrade
- args: [--target-version, "3.2"]
+ args: [--target-version, "4.2"]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
diff --git a/README.rst b/README.rst
index 0eaaa6bd3..2408e1b83 100644
--- a/README.rst
+++ b/README.rst
@@ -44,8 +44,8 @@ Here's a screenshot of the toolbar in action:
In addition to the built-in panels, a number of third-party panels are
contributed by the community.
-The current stable version of the Debug Toolbar is 4.1.0. It works on
-Django ≥ 3.2.4.
+The current stable version of the Debug Toolbar is 4.3.0. It works on
+Django ≥ 4.2.0.
The Debug Toolbar does not currently support `Django's asynchronous views
`_.
diff --git a/docs/changes.rst b/docs/changes.rst
index 3caa35419..a3bf6a934 100644
--- a/docs/changes.rst
+++ b/docs/changes.rst
@@ -4,6 +4,7 @@ Change log
Pending
-------
+* Raised the minimum Django version to 4.2.
* Automatically support Docker rather than having the developer write a
workaround for ``INTERNAL_IPS``.
diff --git a/pyproject.toml b/pyproject.toml
index 944543d91..5e8a47516 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -17,8 +17,6 @@ classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django",
- "Framework :: Django :: 3.2",
- "Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Intended Audience :: Developers",
@@ -37,7 +35,7 @@ dynamic = [
"version",
]
dependencies = [
- "Django>=3.2.4",
+ "Django>=4.2.9",
"sqlparse>=0.2",
]
[project.urls]
diff --git a/tests/test_integration.py b/tests/test_integration.py
index 4cfc84a78..fee67b7d1 100644
--- a/tests/test_integration.py
+++ b/tests/test_integration.py
@@ -266,13 +266,15 @@ def test_render_panel_checks_show_toolbar(self):
response = self.client.get(url, data)
self.assertEqual(response.status_code, 200)
- response = self.client.get(url, data, HTTP_X_REQUESTED_WITH="XMLHttpRequest")
+ response = self.client.get(
+ url, data, headers={"x-requested-with": "XMLHttpRequest"}
+ )
self.assertEqual(response.status_code, 200)
with self.settings(INTERNAL_IPS=[]):
response = self.client.get(url, data)
self.assertEqual(response.status_code, 404)
response = self.client.get(
- url, data, HTTP_X_REQUESTED_WITH="XMLHttpRequest"
+ url, data, headers={"x-requested-with": "XMLHttpRequest"}
)
self.assertEqual(response.status_code, 404)
@@ -302,13 +304,15 @@ def test_template_source_checks_show_toolbar(self):
response = self.client.get(url, data)
self.assertEqual(response.status_code, 200)
- response = self.client.get(url, data, HTTP_X_REQUESTED_WITH="XMLHttpRequest")
+ response = self.client.get(
+ url, data, headers={"x-requested-with": "XMLHttpRequest"}
+ )
self.assertEqual(response.status_code, 200)
with self.settings(INTERNAL_IPS=[]):
response = self.client.get(url, data)
self.assertEqual(response.status_code, 404)
response = self.client.get(
- url, data, HTTP_X_REQUESTED_WITH="XMLHttpRequest"
+ url, data, headers={"x-requested-with": "XMLHttpRequest"}
)
self.assertEqual(response.status_code, 404)
@@ -348,13 +352,15 @@ def test_sql_select_checks_show_toolbar(self):
response = self.client.post(url, data)
self.assertEqual(response.status_code, 200)
- response = self.client.post(url, data, HTTP_X_REQUESTED_WITH="XMLHttpRequest")
+ response = self.client.post(
+ url, data, headers={"x-requested-with": "XMLHttpRequest"}
+ )
self.assertEqual(response.status_code, 200)
with self.settings(INTERNAL_IPS=[]):
response = self.client.post(url, data)
self.assertEqual(response.status_code, 404)
response = self.client.post(
- url, data, HTTP_X_REQUESTED_WITH="XMLHttpRequest"
+ url, data, headers={"x-requested-with": "XMLHttpRequest"}
)
self.assertEqual(response.status_code, 404)
@@ -374,13 +380,15 @@ def test_sql_explain_checks_show_toolbar(self):
response = self.client.post(url, data)
self.assertEqual(response.status_code, 200)
- response = self.client.post(url, data, HTTP_X_REQUESTED_WITH="XMLHttpRequest")
+ response = self.client.post(
+ url, data, headers={"x-requested-with": "XMLHttpRequest"}
+ )
self.assertEqual(response.status_code, 200)
with self.settings(INTERNAL_IPS=[]):
response = self.client.post(url, data)
self.assertEqual(response.status_code, 404)
response = self.client.post(
- url, data, HTTP_X_REQUESTED_WITH="XMLHttpRequest"
+ url, data, headers={"x-requested-with": "XMLHttpRequest"}
)
self.assertEqual(response.status_code, 404)
@@ -406,13 +414,15 @@ def test_sql_explain_postgres_json_field(self):
}
response = self.client.post(url, data)
self.assertEqual(response.status_code, 200)
- response = self.client.post(url, data, HTTP_X_REQUESTED_WITH="XMLHttpRequest")
+ response = self.client.post(
+ url, data, headers={"x-requested-with": "XMLHttpRequest"}
+ )
self.assertEqual(response.status_code, 200)
with self.settings(INTERNAL_IPS=[]):
response = self.client.post(url, data)
self.assertEqual(response.status_code, 404)
response = self.client.post(
- url, data, HTTP_X_REQUESTED_WITH="XMLHttpRequest"
+ url, data, headers={"x-requested-with": "XMLHttpRequest"}
)
self.assertEqual(response.status_code, 404)
@@ -432,13 +442,15 @@ def test_sql_profile_checks_show_toolbar(self):
response = self.client.post(url, data)
self.assertEqual(response.status_code, 200)
- response = self.client.post(url, data, HTTP_X_REQUESTED_WITH="XMLHttpRequest")
+ response = self.client.post(
+ url, data, headers={"x-requested-with": "XMLHttpRequest"}
+ )
self.assertEqual(response.status_code, 200)
with self.settings(INTERNAL_IPS=[]):
response = self.client.post(url, data)
self.assertEqual(response.status_code, 404)
response = self.client.post(
- url, data, HTTP_X_REQUESTED_WITH="XMLHttpRequest"
+ url, data, headers={"x-requested-with": "XMLHttpRequest"}
)
self.assertEqual(response.status_code, 404)
diff --git a/tox.ini b/tox.ini
index 254fb9b76..67436888f 100644
--- a/tox.ini
+++ b/tox.ini
@@ -3,16 +3,13 @@ isolated_build = true
envlist =
docs
packaging
- py{38,39,310}-dj32-{sqlite,postgresql,postgis,mysql}
- py{310,311}-dj41-{sqlite,postgresql,postgis,mysql}
+ py{38,39,310,311,312}-dj{42}-{sqlite,postgresql,postgis,mysql}
py{310,311,312}-dj{42,50,main}-{sqlite,postgresql,psycopg3,postgis,mysql}
[testenv]
deps =
- dj32: django~=3.2.9
- dj41: django~=4.1.3
dj42: django~=4.2.1
- dj50: django~=5.0a1
+ dj50: django~=5.0.2
djmain: https://github.com/django/django/archive/main.tar.gz
postgresql: psycopg2-binary
psycopg3: psycopg[binary]
@@ -37,7 +34,6 @@ passenv=
setenv =
PYTHONPATH = {toxinidir}
PYTHONWARNINGS = d
- py39-dj32-postgresql: DJANGO_SELENIUM_TESTS = true
py311-dj42-postgresql: DJANGO_SELENIUM_TESTS = true
DB_NAME = {env:DB_NAME:debug_toolbar}
DB_USER = {env:DB_USER:debug_toolbar}
@@ -49,28 +45,28 @@ pip_pre = True
commands = python -b -W always -m coverage run -m django test -v2 {posargs:tests}
-[testenv:py{38,39,310,311,312}-dj{32,41,42,50,main}-{postgresql,psycopg3}]
+[testenv:py{38,39,310,311,312}-dj{42,50,main}-{postgresql,psycopg3}]
setenv =
{[testenv]setenv}
DB_BACKEND = postgresql
DB_PORT = {env:DB_PORT:5432}
-[testenv:py{38,39,310,311,312}-dj{32,41,42,50,main}-postgis]
+[testenv:py{38,39,310,311,312}-dj{42,50,main}-postgis]
setenv =
{[testenv]setenv}
DB_BACKEND = postgis
DB_PORT = {env:DB_PORT:5432}
-[testenv:py{38,39,310,311,312}-dj{32,41,42,50,main}-mysql]
+[testenv:py{38,39,310,311,312}-dj{42,50,main}-mysql]
setenv =
{[testenv]setenv}
DB_BACKEND = mysql
DB_PORT = {env:DB_PORT:3306}
-[testenv:py{38,39,310,311,312}-dj{32,41,42,50,main}-sqlite]
+[testenv:py{38,39,310,311,312}-dj{42,50,main}-sqlite]
setenv =
{[testenv]setenv}
DB_BACKEND = sqlite3
From 9f66bd3c2f3d155897f47f19786b8ed7e78ed5ea Mon Sep 17 00:00:00 2001
From: Elineda
Date: Thu, 22 Feb 2024 20:54:19 +0100
Subject: [PATCH 011/200] Improve handling when djdt views dont respond with
JSON (#1877)
---
debug_toolbar/static/debug_toolbar/js/utils.js | 6 +++++-
docs/changes.rst | 2 ++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/debug_toolbar/static/debug_toolbar/js/utils.js b/debug_toolbar/static/debug_toolbar/js/utils.js
index b4c7a4cb8..c37525f13 100644
--- a/debug_toolbar/static/debug_toolbar/js/utils.js
+++ b/debug_toolbar/static/debug_toolbar/js/utils.js
@@ -75,7 +75,11 @@ function ajax(url, init) {
return fetch(url, init)
.then(function (response) {
if (response.ok) {
- return response.json();
+ return response.json().catch(function(error){
+ return Promise.reject(
+ new Error("The response is a invalid Json object : " + error)
+ );
+ });
}
return Promise.reject(
new Error(response.status + ": " + response.statusText)
diff --git a/docs/changes.rst b/docs/changes.rst
index a3bf6a934..3ffa31dea 100644
--- a/docs/changes.rst
+++ b/docs/changes.rst
@@ -7,6 +7,8 @@ Pending
* Raised the minimum Django version to 4.2.
* Automatically support Docker rather than having the developer write a
workaround for ``INTERNAL_IPS``.
+* Display a better error message when the toolbar's requests
+ return invalid json.
4.3.0 (2024-02-01)
------------------
From b9e4af7518d8f61a82055e6cea0900d0ce938411 Mon Sep 17 00:00:00 2001
From: Pascal Fouque
Date: Thu, 22 Feb 2024 21:42:50 +0100
Subject: [PATCH 012/200] Fix DeprecationWarnings about form default templates
(#1878)
Co-authored-by: tschilling
---
debug_toolbar/templates/debug_toolbar/panels/history.html | 2 +-
debug_toolbar/templates/debug_toolbar/panels/history_tr.html | 2 +-
debug_toolbar/templates/debug_toolbar/panels/sql.html | 2 +-
docs/changes.rst | 1 +
4 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/debug_toolbar/templates/debug_toolbar/panels/history.html b/debug_toolbar/templates/debug_toolbar/panels/history.html
index 84c6cb5bd..840f6c9f4 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/history.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/history.html
@@ -1,6 +1,6 @@
{% load i18n %}{% load static %}
diff --git a/debug_toolbar/templates/debug_toolbar/panels/history_tr.html b/debug_toolbar/templates/debug_toolbar/panels/history_tr.html
index 31793472a..eff544f1a 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/history_tr.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/history_tr.html
@@ -43,7 +43,7 @@
|
diff --git a/debug_toolbar/templates/debug_toolbar/panels/sql.html b/debug_toolbar/templates/debug_toolbar/panels/sql.html
index 6080e9f19..e5bf0b7f6 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/sql.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/sql.html
@@ -77,7 +77,7 @@
{% if query.params %}
{% if query.is_select %}