Skip to content

refactor: inline single-use _calculate_base_score adapter - #949

Closed
ebios-star wants to merge 1 commit into
entrius:testfrom
ebios-star:refactor/inline-calculate-base-score-wrapper
Closed

refactor: inline single-use _calculate_base_score adapter#949
ebios-star wants to merge 1 commit into
entrius:testfrom
ebios-star:refactor/inline-calculate-base-score-wrapper

Conversation

@ebios-star

Copy link
Copy Markdown
Contributor

Summary

_calculate_base_score in gittensor/validator/oss_contributions/mirror/scoring.py is described in its own docstring as a "Thin wrapper: run the shared helper and copy fields onto ScoredMirrorPR" and has exactly one caller (score_mirror_pr).

The wrapper mutates seven fields on scored while returning only base_score, hiding most of its side effects behind a misleading return signature — the only visible mutation at the call site is scored.base_score = .... Inlining moves the field-copying out into the caller alongside that existing assignment, so all eight mutations land on one block in score_mirror_pr.

The shared helper calculate_base_score_for_pr_files (which actually performs the computation) is unaffected and still callable from any future non-mutating consumer.

grep -rn _calculate_base_score confirms no other call sites or test references in gittensor/, neurons/, or tests/.

Net: -20 / +9 lines, one fewer module-level helper.

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other

Testing

  • pytest tests/ — all 726 tests pass.

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Changes are documented (if applicable)

…mirror_pr

The private `_calculate_base_score` is described in its own docstring as a
'Thin wrapper: run the shared helper and copy fields onto ScoredMirrorPR'
and has exactly one caller. It mutates seven fields on `scored` while
returning only `base_score`, hiding the bulk of its side effects behind
a misleading return signature.

Inlining moves the field-copying out into the caller alongside the
`scored.base_score = ...` assignment that already lived there, so all
eight mutations are visible on one block. The shared helper
`calculate_base_score_for_pr_files` (which actually computes the
score) is unaffected and still callable from any future site that
wants a non-mutating result.

`grep -rn _calculate_base_score` confirms no other call sites or test
references in `gittensor/`, `neurons/`, or `tests/`.
@xiao-xiao-mao xiao-xiao-mao Bot added the refactor Code restructuring without behavior change label May 3, 2026
@ebios-star

Copy link
Copy Markdown
Contributor Author

@anderdc whenever you have a moment, this is a small inline of a single-use adapter that the wrapper itself describes as a thin wrapper. Happy to revise or scope differently if you'd prefer. Thanks!

@anderdc anderdc mentioned this pull request May 5, 2026
8 tasks
@anderdc

anderdc commented May 5, 2026

Copy link
Copy Markdown
Collaborator

Closing — please consolidate into #917.

@anderdc anderdc closed this May 5, 2026
@ebios-star

Copy link
Copy Markdown
Contributor Author

Consolidated into #955 per @anderdc's request.

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.

2 participants