Skip to content

refactor: centralize ALPHA_DECIMALS / ALPHA_RAW_UNIT in gittensor/constants.py - #1380

Closed
ebios-star wants to merge 2 commits into
entrius:testfrom
ebios-star:refactor/centralize-alpha-raw-unit
Closed

refactor: centralize ALPHA_DECIMALS / ALPHA_RAW_UNIT in gittensor/constants.py#1380
ebios-star wants to merge 2 commits into
entrius:testfrom
ebios-star:refactor/centralize-alpha-raw-unit

Conversation

@ebios-star

Copy link
Copy Markdown
Contributor

Summary

The raw → display alpha conversion factor (10^9) was defined locally in cli/issue_commands/helpers.py:39-40 and re-implemented as the magic literal 1e9 at two validator sites that print bounty / treasury-stake amounts:

This PR hoists ALPHA_DECIMALS and ALPHA_RAW_UNIT into gittensor/constants.py (next to MAX_ISSUE_ID) so all three sites share one definition. Validator code now imports the constant directly from gittensor.constants instead of carrying its own magic number or reaching into cli/* for it.

CLI tests in tests/cli/test_cli_helpers.py that import ALPHA_DECIMALS / ALPHA_RAW_UNIT from gittensor.cli.issue_commands.helpers continue to work unchanged — helpers.py re-binds both names via its existing from gittensor.constants import ... line, so the public attribute on the helpers module is preserved.

Same shape as the merged #1015 (move MAX_ISSUE_ID to gittensor/constants.py) and the import-direction precedent in #425 (NETWORK_MAP) and #460 (get_contract_address).

Net: +9 / -6 lines across 4 files.

Type of Change

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

Testing

  • pytest tests/ — all 838 tests pass.

Checklist

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

…rencing_prs_graphql

_resolve_pr_state was a 5-line wrapper used at exactly one site (in
_search_issue_referencing_prs_graphql). Its body is a single expression —
'MERGED' when the GraphQL response's merged flag is set, otherwise the
uppercased state with 'OPEN' as the empty-string fallback — so the inline
form is just as readable at the call site.

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

Matches the merged single-use-helper-inline pattern from entrius#748 (inline
get_github_user into get_github_id) and entrius#818 (inline _single_paragraph
/ _get_contract_info_value). Same shape as my own merged inlines in
entrius#917's bundle.
…stants.py

The raw → display alpha conversion factor (10^9) was defined locally
in cli/issue_commands/helpers.py and re-implemented as the magic literal
1e9 at two validator sites that print bounty / treasury-stake amounts:

  - validator/issue_competitions/forward.py:87
  - validator/issue_competitions/contract_client.py:606

Hoists the two constants into gittensor/constants.py (next to MAX_ISSUE_ID)
so all three sites share one definition. Validator code now imports the
constant directly from gittensor.constants instead of carrying its own
magic number or reaching into cli/* for it.

CLI tests in tests/cli/test_cli_helpers.py that import ALPHA_DECIMALS /
ALPHA_RAW_UNIT from gittensor.cli.issue_commands.helpers continue to work
unchanged — helpers.py re-binds both names via its existing constants
import, so the public attribute on the helpers module is preserved.

Same shape as the merged entrius#1015 (move MAX_ISSUE_ID to gittensor/constants.py)
and the import-direction precedent in entrius#425 (NETWORK_MAP) and entrius#460
(get_contract_address).
@ebios-star

Copy link
Copy Markdown
Contributor Author

@anderdc whenever you have a moment, this centralizes the raw → display alpha conversion so the two validator sites stop carrying the 1e9 magic literal. Happy to revise scope if you'd prefer. Thanks!

@xiao-xiao-mao xiao-xiao-mao Bot added the refactor Code restructuring without behavior change label May 27, 2026
@anderdc

anderdc commented May 29, 2026

Copy link
Copy Markdown
Collaborator

This PR is described as centralizing the ALPHA constants across 4 files, but it also deletes _resolve_pr_state in gittensor/utils/github_api_tools.py — an unrelated change not in the description. That helper is still called at github_api_tools.py:442 (the ClosedEvent closer path), which the diff doesn't touch, so the deletion leaves a dangling reference. Closing.

@anderdc anderdc closed this May 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.

2 participants