Skip to content

refactor: inline single-use _single_paragraph and _get_contract_info_value helpers#818

Open
ebios-star wants to merge 2 commits intoentrius:testfrom
ebios-star:refactor/inline-single-paragraph-helper
Open

refactor: inline single-use _single_paragraph and _get_contract_info_value helpers#818
ebios-star wants to merge 2 commits intoentrius:testfrom
ebios-star:refactor/inline-single-paragraph-helper

Conversation

@ebios-star
Copy link
Copy Markdown
Contributor

@ebios-star ebios-star commented Apr 27, 2026

Summary

Folded #819 into this PR per @anderdc's review. Two single-use module-level helpers inlined into their only callers:

  1. _single_paragraph in gittensor/cli/issue_commands/help.py — 3-line wrapper around ' '.join(text.split()), called only from StyledGroup.get_help. Inlined idiom is conventional Python for collapsing whitespace.

  2. _get_contract_info_value in gittensor/validator/issue_competitions/storage_utils.py — 3-line wrapper around contract_info.value if hasattr(contract_info, 'value') else contract_info, called only from _extract_trie_id_bytes. The hasattr fallback is preserved verbatim so all three substrate trie_id shapes (str/bytes/list) covered by test_get_contract_child_storage_key_accepts_multiple_trie_id_formats still resolve identically.

grep -rn confirms a single call site for each helper, no test references.

Net: -12 / +2 lines combined, two fewer private helpers.

Type of Change

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

Testing

  • uv run --extra dev pytest tests/ — all 652 tests pass.
  • tests/utils/test_issue_competitions_storage_utils.py (14 tests, including the multi-format trie_id test) covers the storage_utils path and still passes.

Checklist

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

@xiao-xiao-mao xiao-xiao-mao Bot added the refactor Code restructuring without behavior change label Apr 27, 2026
@ebios-star
Copy link
Copy Markdown
Contributor Author

@anderdc @LandynDev — friendly ping for review when you have a moment.

Same family as #748 (merged) and #641. _single_paragraph was a 3-line wrapper around ' '.join(text.split()) called from one place; the inlined idiom reads as cleanly. grep confirms a single call site, no test references. -6/+1 lines, full test suite passes.

Happy to rebase if needed.

@anderdc
Copy link
Copy Markdown
Collaborator

anderdc commented Apr 28, 2026

Fold your #819 changes into this. No need to have had them separated

Copy link
Copy Markdown
Collaborator

@anderdc anderdc left a comment

Choose a reason for hiding this comment

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

Fold all your inline PRs into this one. no need to separate them.

_single_paragraph in cli/issue_commands/help.py was a 3-line wrapper
around `' '.join(text.split())`, called from exactly one place
(StyledGroup.get_help). Inlining matches the pattern from entrius#748 / entrius#641
(remove single-use indirection); the inlined idiom is conventional
Python for collapsing whitespace and reads just as clearly at the
call site.

`grep -rn _single_paragraph` confirms no other call sites in
gittensor/, neurons/, or tests/. No behaviour change — full test
suite passes.
_get_contract_info_value in validator/issue_competitions/storage_utils.py
was a 3-line wrapper around `contract_info.value if hasattr(...) else
contract_info`, called from exactly one place (_extract_trie_id_bytes).
Inlining matches the pattern from entrius#748 / entrius#641 (remove single-use
indirection).

`grep -rn _get_contract_info_value` confirms no other call sites in
gittensor/, neurons/, or tests/. The hasattr fallback is preserved
verbatim, so all three substrate trie_id shapes covered by
test_get_contract_child_storage_key_accepts_multiple_trie_id_formats
(str/bytes/list) still resolve identically. Full test suite passes.
@ebios-star ebios-star force-pushed the refactor/inline-single-paragraph-helper branch from 61860ba to 78857cb Compare April 28, 2026 23:43
@ebios-star ebios-star changed the title refactor: inline single-use _single_paragraph helper refactor: inline single-use _single_paragraph and _get_contract_info_value helpers Apr 28, 2026
@ebios-star
Copy link
Copy Markdown
Contributor Author

Done @anderdc — folded #819 into this PR.

Branch is now rebased onto current test and contains two commits: the original _single_paragraph inline plus the cherry-picked _get_contract_info_value inline. Title and description updated to cover both. Force-pushed with --force-with-lease. All 652 tests pass.

Happy to squash to a single commit if you'd prefer that shape.

@ebios-star
Copy link
Copy Markdown
Contributor Author

Hi @anderdc — thanks for the quick review and clear direction on the consolidation. The requested fold is in: this PR now contains both inline-helper commits, rebased onto current test, with the description updated to cover both. CI is green on my end (652/652).

Whenever you have a moment for a re-review, I'd really appreciate it. Happy to address any further feedback or squash to a single commit if that shape works better for you.

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