From 7fdc011b4840ec0f058b84cf8b4d097c39064633 Mon Sep 17 00:00:00 2001 From: saravanakumardb1 Date: Sat, 23 May 2026 15:28:30 -0700 Subject: [PATCH] feat(scripts): T5.3 \u2014 python-print scanner refinements (351 \u2192 0) Of 351 findings, 346 were in mac_tooling/tools/*.py (forensics CLI scripts with __main__ blocks invoked directly). Per Q2 in docs/AGENT_COMPLIANCE_ROADMAP.md and the mac_tooling repo's own AGENTS.md "Differences from ByteLyst Product Repos" section, the toolkit is a standalone CLI without the ByteLyst Fastify/structlog conventions. Scanner refinements: + Repo-level exemption: learning_ai_mac_tooling (matches existing hex-rule exemption for the same reason). + Honor '# noqa: T201' (flake8/ruff's print-found rule), both inline and on the preceding line \u2014 the canonical Python opt-out for intentional terminal output. The remaining 5 voice_ai_agent findings fall into two categories: - cli_output.py already had '# noqa: T201' (now respected, cleared). - sounds.py (terminal BEL audio fallback) + fn_listener.py (user-facing startup error on Accessibility-permission failure) get '# noqa: T201' in the next two commits. scripts/check-rule-violations.sh: 351 \u2192 0 b4-python-print findings. --- scripts/check-rule-violations.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/check-rule-violations.sh b/scripts/check-rule-violations.sh index 1c2e33e6..e8d1eba8 100644 --- a/scripts/check-rule-violations.sh +++ b/scripts/check-rule-violations.sh @@ -226,6 +226,16 @@ scan_b4_python_print() { [[ "$evidence" =~ ^[[:space:]]*# ]] && continue # Skip CLI entrypoint files (often named cli.py, __main__.py). [[ "$file" =~ /(cli|__main__|main)\.py$ ]] && continue + # Skip mac_tooling \u2014 standalone macOS forensics CLI per its AGENTS.md. + # tools/*.py all have `if __name__ == "__main__":` and are invoked + # directly as CLI scripts. + [[ "$repo" == "learning_ai_mac_tooling" ]] && continue + # Honor `# noqa: T201` (flake8 / ruff's "print found" rule). Either + # inline on the same line or on the preceding line. + [[ "$evidence" =~ \#[[:space:]]*noqa([[:space:]]*:[^#]*T201) ]] && continue + if [[ "$line" -gt 1 ]] && sed -n "$((line - 1))p" "$file" 2>/dev/null | grep -qE '# noqa:[^#]*T201'; then + continue + fi emit_finding "b4-python-print" "major" "$repo" "$file" "$line" "Python print(): ${evidence:0:80}" done < <(grep -rnE '^\s*print\(' "${repo_dir}/${src}" --include='*.py' \ --exclude-dir=tests --exclude='test_*.py' --exclude='*_test.py' \