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.
This commit is contained in:
parent
51d9b6b55f
commit
7fdc011b48
@ -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' \
|
||||
|
||||
Loading…
Reference in New Issue
Block a user