Skip to content

Commit

Permalink
Deprecate OBSERVE_REQUEST_CALLBACK
Browse files Browse the repository at this point in the history
With the addition of the UPDATE_ON_FETCH setting, the
OBSERVE_REQUEST_CALLBACK setting is redundant.  Thus add a check
debug_toolbar.W008 to warn if it is present in DEBUG_TOOLBAR_CONFIG,
but do not remove it yet.

See jazzband#1886
  • Loading branch information
living180 committed Mar 11, 2024
1 parent cfd4801 commit 5afd807
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
15 changes: 15 additions & 0 deletions debug_toolbar/apps.py
Expand Up @@ -206,3 +206,18 @@ def js_mimetype_check(app_configs, **kwargs):
)
]
return []


@register()
def check_settings(app_configs, **kwargs):
errors = []
USER_CONFIG = getattr(settings, "DEBUG_TOOLBAR_CONFIG", {})
if "OBSERVE_REQUEST_CALLBACK" in USER_CONFIG:
errors.append(
Warning(
"Specifying OBSERVE_REQUEST_CALLBACK in DEBUG_TOOLBAR_CONFIG is deprecated.",
hint="Use the UPDATE_ON_FETCH and SHOW_TOOLBAR_CALLBACK settings instead.",
id="debug_toolbar.W008",
)
)
return errors
3 changes: 3 additions & 0 deletions docs/changes.rst
Expand Up @@ -17,6 +17,9 @@ Pending
:class:`StaticFilesPanel <debug_toolbar.panels.staticfiles.StaticFilesPanel>`
since that check is made redundant by a similar check in Django 4.0 and
later.
* Deprecated the ``OBSERVE_REQUEST_CALLBACK`` setting and added check
``debug_toolbar.W008`` to warn when it is specified in
``DEBUG_TOOLBAR_SETTINGS``.

4.3.0 (2024-02-01)
------------------
Expand Down
16 changes: 16 additions & 0 deletions tests/test_checks.py
Expand Up @@ -235,3 +235,19 @@ def test_check_w007_invalid(self, mocked_guess_type):
)
],
)

@override_settings(
DEBUG_TOOLBAR_CONFIG={"OBSERVE_REQUEST_CALLBACK": lambda request: False}
)
def test_observe_request_callback_specified(self):
errors = run_checks()
self.assertEqual(
errors,
[
Warning(
"Specifying OBSERVE_REQUEST_CALLBACK in DEBUG_TOOLBAR_CONFIG is deprecated.",
hint="Use the UPDATE_ON_FETCH and SHOW_TOOLBAR_CALLBACK settings instead.",
id="debug_toolbar.W008",
)
],
)

0 comments on commit 5afd807

Please sign in to comment.