Skip to content

refactor: inline single-use _zero_for_duplicate_penalty#870

Open
bitcompass wants to merge 2 commits intoentrius:testfrom
bitcompass:refactor/inline-zero-for-duplicate-penalty
Open

refactor: inline single-use _zero_for_duplicate_penalty#870
bitcompass wants to merge 2 commits intoentrius:testfrom
bitcompass:refactor/inline-zero-for-duplicate-penalty

Conversation

@bitcompass
Copy link
Copy Markdown

Summary

Inlines _zero_for_duplicate_penalty into its single call site in detect_and_penalize_miners_sharing_github
(gittensor/validator/oss_contributions/inspections.py) and removes the helper.

The helper existed for readability, but it had exactly one caller and the field-list lived behind a function jump. The function's own docstring already warned: "when adding new score-bearing fields to MinerEvaluation, update this function so the penalty stays comprehensive — a forgotten field would let a penalized miner retain partial credit in that dimension." Inlining makes that risk self-evident at code review time: adding a new score field to MinerEvaluation now lands next to the zeroing block in the same diff hunk.

The reminder comment is preserved next to the inlined block.

No behavioural change. Same fields zeroed in the same order.

Related Issues

Fixes #869

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Testing

  • Tests added/updated
  • Manually tested

The existing test tests/validator/test_duplicate_penalty_propagation.py exercises detect_and_penalize_miners_sharing_github end-to-end and covers the zeroing block via its public entry point. No new tests are
needed because the refactor is mechanical (function body moved verbatim into the loop body); test surface and assertions are
unchanged.

Verified locally:

uv run pre-commit run --all-files
uv run pre-commit run --all-files --hook-stage pre-push
uv run pytest tests/validator/test_duplicate_penalty_propagation.py -v

@xiao-xiao-mao xiao-xiao-mao Bot added the refactor Code restructuring without behavior change label Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code restructuring without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor] Inline _zero_for_duplicate_penalty (single call site, fragile field list)

1 participant