refactor: bundle of small refactors - #917
Merged
anderdc merged 11 commits intoMay 6, 2026
Merged
Conversation
Contributor
Author
This was referenced May 5, 2026
anderdc
previously approved these changes
May 5, 2026
Collaborator
|
still need to consolidate your PRs here |
Collaborator
|
awaiting consolidation still, or I will close this PR |
…ers.py Two `validate_repository` / `validate_github_issue` requests hardcoded `https://api.github.com/...` instead of reusing the existing `gittensor.constants.BASE_GITHUB_API_URL`. The file already imports from `gittensor.constants` (NETWORK_MAP); just add the existing constant alongside. Same shape as entrius#455 (use shared NETWORK_CHOICE constant).
…out=15 sites `gittensor/utils/github_api_tools.py` already imports `GITHUB_HTTP_TIMEOUT_SECONDS` from `gittensor.constants` and uses it for the `/user` request. Three other GitHub HTTP calls in the same file (`get_merge_base_sha`, `get_pull_request_file_changes`, `check_github_issue_closed`) still passed the literal `15`. Switch them to the constant so a future timeout tweak doesn't need to be applied in four places.
These three constants were only referenced by gittensor/validator/issue_discovery/repo_scan.py, which was deleted in entrius#796 when issue discovery was routed through das-github-mirror. Verified zero remaining callers across the codebase.
Two private 3-line wrappers each have exactly one caller in their own module: - get_github_pat (cli/issue_commands/helpers.py) wraps a single os.environ.get; the caller already does '... or ""', so the wrapper's 'or None' fallback is collapsed away on inline. - is_comment_node (validator/utils/tree_sitter_scoring.py) wraps a single 'node.type in COMMENT_NODE_TYPES' membership check. grep confirms no other call sites or test references in gittensor/, neurons/, or tests/.
…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/`.
…OOT_KEY The ink! storage selector '52789899' for the issues mapping is duplicated at the two active call sites that compute lazy keys for child storage reads: - validator/issue_competitions/contract_client.py (read_issue_from_child_storage) - cli/issue_commands/helpers.py (_read_issues_from_child_storage) Both already import from validator/issue_competitions/storage_utils, so this hoists the literal into a single named constant in storage_utils and updates both call sites to use it. If the contract storage layout ever changes, the selector now lives in one place beside the other storage-decoding helpers.
U32_MAX is defined in neurons/base/utils/weight_utils.py but has zero references across gittensor/, neurons/, and tests/. The sibling U16_MAX is actively used by convert_weights_and_uids_for_emit and process_weights_for_netuid. Verified via 'grep -rn U32_MAX' and 'grep -rn 4294967295' — both return only the definition line.
GITHUB_DOMAIN is defined at module scope in gittensor/classes.py but has zero references anywhere in gittensor/, neurons/, or tests/. The sites that build GitHub URLs use inline f-strings (e.g. f'https://github.com/{repo}/issues/{issue_number}') and don't import this constant. Verified via 'grep -rn GITHUB_DOMAIN' — only the definition line.
The other two consumers of __version__ (gittensor/cli/main.py and tests/cli/test_miner_commands.py) write 'from gittensor import __version__'. neurons/validator.py used the non-canonical 'from gittensor.__init__ import __version__' form, which Python resolves identically but reads as if it were targeting an internal implementation file rather than the package's public surface.
…he validator side Follow-up to entrius#873 which deduped the 1_000_000 issue-ID bound on the CLI side using the helpers.py-local MAX_ISSUE_ID. The validator-side path in IssueCompetitionContractClient.get_issues_by_status still carried its own local 'MAX_REASONABLE_ISSUE_ID = 1_000_000' with the same value and same intent. Hoists MAX_ISSUE_ID into gittensor/constants.py (alongside the other issues-competition constants) so both consumers share one definition. Validator code stays clean of any cli/* dependency, matching the import-direction precedent in entrius#425 (NETWORK_MAP) and entrius#460 (get_contract_address).
ebios-star
force-pushed
the
refactor/use-base-github-api-url-constant
branch
from
May 6, 2026 21:11
4c0636f to
143c216
Compare
8 tasks
Contributor
Author
|
@anderdc done — force-pushed this branch with the 10 commits consolidated (#917 plus #942, #943, #948, #949, #952, #953, #954, #955, #1015). Each commit is preserved individually so the bundle can be reviewed commit-by-commit or squash-merged. #864 still mid-review; #873 has since merged and the last commit here builds on it. Thanks for the review! |
anderdc
approved these changes
May 6, 2026
anderdc
approved these changes
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Per @anderdc's review, consolidating my open small refactor PRs into this one. #864 and #873 are mid-review and remain separate as previously requested. (Note: #873 has since merged — its work is built on by the last commit here.)
Each commit is preserved as a separate revision so the bundle can be reviewed commit-by-commit or squash-merged.
Commits in this bundle (oldest → newest)
refactor: use BASE_GITHUB_API_URL constant in cli/issue_commands/helpers.pyrefactor: use GITHUB_HTTP_TIMEOUT_SECONDS at the three remaining timeout=15 sitesrefactor: remove unused REPO_SCAN_* constantsrefactor: inline single-use get_github_pat and is_comment_node helpersrefactor: inline single-use _calculate_base_score adapter into score_mirror_prrefactor: centralize ink! issues-mapping selector as ISSUES_MAPPING_ROOT_KEYrefactor: remove unused U32_MAX constantrefactor: remove unused GITHUB_DOMAIN constantrefactor: normalize __version__ import in neurons/validator.pyrefactor: move MAX_ISSUE_ID to gittensor/constants.py and use it on the validator side(follow-up to merged refactor: dedupe the 1_000_000 issue-ID bound in cli/issue_commands/helpers.py #873)Aggregate change
Type of Change
Testing
pytest tests/on the merged bundle — all 754 tests pass.Checklist