Skip to content

[codex] Handle empty files in partial port audit - #138

Merged
Vilin97 merged 1 commit into
mainfrom
codex/fix-partial-port-zero-loc
Jun 2, 2026
Merged

Vilin97 merged 1 commit into
mainfrom
codex/fix-partial-port-zero-loc

Conversation

@Vilin97

@Vilin97 Vilin97 commented May 28, 2026

Copy link
Copy Markdown
Collaborator

What changed

  • Skips zero-LOC upstream files when computing matched-file truncation ratios in the partial-port audit.
  • Adds a regression test covering empty matched upstream files.

Why

Running the audit against import/hopfieldnet exposed a ZeroDivisionError when an upstream file had zero non-comment LOC. That made the advisory audit crash instead of reporting the actual partial-port signal.

Validation

  • cd python && uv run --group test pytest tests/test_partial_port_audit.py
  • cd python && uv run ruff check lean_pool/partial_port_audit.py tests/test_partial_port_audit.py
  • cd python && uv run python -m lean_pool.partial_port_audit --repo .. --base-ref origin/main --head-ref import/hopfieldnet --json

@Vilin97
Vilin97 marked this pull request as ready for review May 28, 2026 13:07
Copilot AI review requested due to automatic review settings May 28, 2026 13:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a ZeroDivisionError in the partial-port audit when an upstream Lean file has zero non-comment LOC by skipping such files during the matched-file truncation ratio computation, and adds a regression test.

Changes:

  • Skip zero-LOC upstream files in evaluate_stats truncation loop.
  • Add regression test for empty matched upstream files.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
python/lean_pool/partial_port_audit.py Guards the truncation-ratio loop against zero-LOC upstream files.
python/tests/test_partial_port_audit.py Adds regression test verifying empty upstream files do not cause divide-by-zero.

@Vilin97
Vilin97 merged commit aa3ea39 into main Jun 2, 2026
6 of 7 checks passed
@Vilin97
Vilin97 deleted the codex/fix-partial-port-zero-loc branch June 2, 2026 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants