From 666fb027c6fe55e7bc94995d2a3a65d96a7b47d7 Mon Sep 17 00:00:00 2001 From: JessicaBell00 <110268278+JessicaBell00@users.noreply.github.com> Date: Tue, 20 Aug 2024 17:37:36 +1200 Subject: [PATCH] Make logging levels case insensitive Added '.lower()' to string being parsed for logging. --- .../pylint_guidelines_checker.py | 2 +- .../tests/test_pylint_custom_plugins.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/pylint-extensions/azure-pylint-guidelines-checker/pylint_guidelines_checker.py b/tools/pylint-extensions/azure-pylint-guidelines-checker/pylint_guidelines_checker.py index 08011784844..f5441fc8f5f 100644 --- a/tools/pylint-extensions/azure-pylint-guidelines-checker/pylint_guidelines_checker.py +++ b/tools/pylint-extensions/azure-pylint-guidelines-checker/pylint_guidelines_checker.py @@ -2762,7 +2762,7 @@ def check_for_logging(self, node): matches = [".warning", ".error"] for j in node: if isinstance(j, astroid.Expr): - expression = j.as_string() + expression = j.as_string().lower() if any(x in expression for x in matches): self.add_message( msgid=f"do-not-log-raised-errors", diff --git a/tools/pylint-extensions/azure-pylint-guidelines-checker/tests/test_pylint_custom_plugins.py b/tools/pylint-extensions/azure-pylint-guidelines-checker/tests/test_pylint_custom_plugins.py index e2276ae13a9..8281b25fbbb 100644 --- a/tools/pylint-extensions/azure-pylint-guidelines-checker/tests/test_pylint_custom_plugins.py +++ b/tools/pylint-extensions/azure-pylint-guidelines-checker/tests/test_pylint_custom_plugins.py @@ -4844,7 +4844,7 @@ def test_error_level_not_logged(self): try: #@ add = 1 + 2 except Exception as e: - logger.error(str(e)) #@ + logger.ERROR(str(e)) #@ raise ''' )