From a15b0c821d09b7a33fa9158322fe7835c3787a89 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 10 May 2026 16:58:45 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20ruff:=20enable=20BLE=20catch-all?= =?UTF-8?q?=20rule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds flake8-blind-except (BLE) to ruff's selected rules so bare `except:`, `except Exception:`, and `except BaseException:` are flagged. Forces a deliberate choice on error handling - either narrow the exception or add `# noqa: BLE001` with a justification. Annotates the two existing legitimate broad catches (test thread error collection, observability fallback) with reason comments. https://claude.ai/code/session_01LKvQDaUrRDui7ZQRkHH4Cp --- pyproject.toml | 2 +- tests/test_logging_thread_safety.py | 2 +- utils/llm/dspy_langfuse.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2a46fac..386aa17 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,7 @@ line-length = 88 target-version = "py312" [tool.ruff.lint] -select = ["E", "F", "W", "I", "N", "UP", "B", "C4", "SIM", "C901", "FIX"] +select = ["E", "F", "W", "I", "N", "UP", "B", "C4", "SIM", "C901", "FIX", "BLE"] ignore = ["E501", "UP015", "B008"] [tool.ruff.lint.mccabe] diff --git a/tests/test_logging_thread_safety.py b/tests/test_logging_thread_safety.py index 9aef2eb..137fb6f 100644 --- a/tests/test_logging_thread_safety.py +++ b/tests/test_logging_thread_safety.py @@ -30,7 +30,7 @@ def call_setup(): try: barrier.wait(timeout=5) logging_module.setup_logging() - except Exception as e: + except Exception as e: # noqa: BLE001 - test collects any thread failure errors.append(e) threads = [threading.Thread(target=call_setup) for _ in range(10)] diff --git a/utils/llm/dspy_langfuse.py b/utils/llm/dspy_langfuse.py index d1bf7c2..91dd442 100644 --- a/utils/llm/dspy_langfuse.py +++ b/utils/llm/dspy_langfuse.py @@ -102,7 +102,7 @@ def on_module_end( # noqa outputs_extracted = dict(outputs.items()) except AttributeError: outputs_extracted = {"value": outputs} - except Exception as e: + except Exception as e: # noqa: BLE001 - observability fallback must never raise outputs_extracted = {"error_extracting_module_output": str(e)} get_client().update_current_span( input=self.input_field_values.get(None) or {},