From 95a804334160248dd9112cef1aa8e1c1e26e07fb Mon Sep 17 00:00:00 2001 From: "rodrigo.nogueira" Date: Mon, 29 Dec 2025 10:58:44 -0300 Subject: [PATCH] Fix AttributeError when optional settings are undefined Fixes #1328 - Add None as default value in axes_conf_check - Add test coverage for missing settings scenario --- axes/checks.py | 2 +- tests/test_checks.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/axes/checks.py b/axes/checks.py index 3cd0e64..e6009b5 100644 --- a/axes/checks.py +++ b/axes/checks.py @@ -207,7 +207,7 @@ def axes_conf_check(app_configs, **kwargs): # pylint: disable=unused-argument ] for callable_setting in callable_settings: - value = getattr(settings, callable_setting) + value = getattr(settings, callable_setting, None) if not is_valid_callable(value): warnings.append( Warning( diff --git a/tests/test_checks.py b/tests/test_checks.py index b9ed5f6..821cf6e 100644 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -129,3 +129,8 @@ class ConfCheckTestCase(AxesTestCase): def test_valid_callable(self): warnings = run_checks() self.assertEqual(warnings, []) + + def test_missing_settings_no_error(self): + warnings = run_checks() + self.assertEqual(warnings, []) +