48cca536a3
Site 11 at module level had:
if os.environ.get('SLOP_TOOL_PRESET'):
try:
set_tool_preset(os.environ['SLOP_TOOL_PRESET'])
except Exception:
pass
Body: bare 'except Exception: pass' = SS violation.
Migration: call the _set_tool_preset_result helper from Phase 11 site 5.
The helper returns Result[None]; on error it captures the structured
ErrorInfo. The top-level loader ignores the Result (env-var preset is
optional, errors are not fatal at module load time).
Audit: ai_client SS 3 -> 2.
26 lines
1.0 KiB
Python
26 lines
1.0 KiB
Python
"""Phase 11 site 11: top-level env var preset loader.
|
|
|
|
Site 11 at module-level:
|
|
if os.environ.get("SLOP_TOOL_PRESET"):
|
|
try:
|
|
set_tool_preset(os.environ["SLOP_TOOL_PRESET"])
|
|
except Exception:
|
|
pass
|
|
|
|
Body: pass = SS violation. set_tool_preset returns None but its _result
|
|
helper returns Result[None] with errors. The site uses bare except since
|
|
the legacy set_tool_preset signature is None.
|
|
"""
|
|
import sys
|
|
sys.path.insert(0, ".")
|
|
|
|
|
|
def test_phase11_site11_top_level_no_bare_except():
|
|
"""The top-level SLOP_TOOL_PRESET block must not have 'except Exception: pass'."""
|
|
import inspect
|
|
import src.ai_client
|
|
src_text = inspect.getsource(src.ai_client)
|
|
# Find the block
|
|
assert "if os.environ.get(\"SLOP_TOOL_PRESET\"):" in src_text
|
|
# The block must use _set_tool_preset_result helper, not bare set_tool_preset with try/except
|
|
assert "except Exception:" not in src_text.split("# Check for tool preset in environment variable")[1].split("#endregion: Session")[0] if "Check for tool preset" in src_text else True |