From 981492bb33d94c8d2584f3dba901b8b9e7c2e7cb Mon Sep 17 00:00:00 2001 From: stumpylog <797416+stumpylog@users.noreply.github.com> Date: Thu, 27 Aug 2026 10:21:27 -0700 Subject: [PATCH] Chore: enable flake8-bandit S102/S110/S112 ruff rules 3 S110 (try-except-pass) hits, all fixed by adding a log call in the except block rather than silently swallowing the exception, matching this codebase's existing %s lazy-formatting logging convention. Behavior is unchanged (still no re-raise) in all three spots. --- pyproject.toml | 3 +++ src/documents/consumer.py | 2 +- src/documents/signals/handlers.py | 2 +- src/documents/views.py | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 18602d8ec..b221c8290 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -269,6 +269,9 @@ extend-select = [ "Q", # https://docs.astral.sh/ruff/rules/#flake8-quotes-q "RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse "RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf + "S102", # https://docs.astral.sh/ruff/rules/#flake8-bandit-s + "S110", # https://docs.astral.sh/ruff/rules/#flake8-bandit-s + "S112", # https://docs.astral.sh/ruff/rules/#flake8-bandit-s "SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim "T100", # https://docs.astral.sh/ruff/rules/#flake8-debugger-t10 "T20", # https://docs.astral.sh/ruff/rules/#flake8-print-t20 diff --git a/src/documents/consumer.py b/src/documents/consumer.py index 970a259fd..fc13c959f 100644 --- a/src/documents/consumer.py +++ b/src/documents/consumer.py @@ -970,7 +970,7 @@ class ConsumerPlugin( try: copy_basic_file_stats(source, target) except Exception: # pragma: no cover - pass + self.log.debug("Unable to copy file stats from %s to %s", source, target) class ConsumerPreflightPlugin( diff --git a/src/documents/signals/handlers.py b/src/documents/signals/handlers.py index b76759781..c00be0e33 100644 --- a/src/documents/signals/handlers.py +++ b/src/documents/signals/handlers.py @@ -637,7 +637,7 @@ def update_filename_and_move_files( # so this is not the end of the world. # B: if moving the original file failed, nothing has changed # anyway. - pass + logger.exception("Error reverting document changes") # restore old values on the instance instance.filename = old_filename diff --git a/src/documents/views.py b/src/documents/views.py index c3e3c950b..cd1f1fd4f 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -1449,7 +1449,7 @@ class DocumentViewSet( try: lang = detect(doc.content) except Exception: - pass + logger.debug("Unable to detect language for document %s", doc.pk) meta["lang"] = lang return Response(meta)