Skip to content

Commit 80eda12

Browse files
Miyamura80claude
andauthored
🔨 ruff: enable BLE catch-all rule (#165)
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 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 74c408c commit 80eda12

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ line-length = 88
5555
target-version = "py312"
5656

5757
[tool.ruff.lint]
58-
select = ["E", "F", "W", "I", "N", "UP", "B", "C4", "SIM", "C901", "FIX"]
58+
select = ["E", "F", "W", "I", "N", "UP", "B", "C4", "SIM", "C901", "FIX", "BLE"]
5959
ignore = ["E501", "UP015", "B008"]
6060

6161
[tool.ruff.lint.mccabe]

tests/test_logging_thread_safety.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def call_setup():
3030
try:
3131
barrier.wait(timeout=5)
3232
logging_module.setup_logging()
33-
except Exception as e:
33+
except Exception as e: # noqa: BLE001 - test collects any thread failure
3434
errors.append(e)
3535

3636
threads = [threading.Thread(target=call_setup) for _ in range(10)]

utils/llm/dspy_langfuse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def on_module_end( # noqa
102102
outputs_extracted = dict(outputs.items())
103103
except AttributeError:
104104
outputs_extracted = {"value": outputs}
105-
except Exception as e:
105+
except Exception as e: # noqa: BLE001 - observability fallback must never raise
106106
outputs_extracted = {"error_extracting_module_output": str(e)}
107107
get_client().update_current_span(
108108
input=self.input_field_values.get(None) or {},

0 commit comments

Comments
 (0)