Skip to content

chore: integrate pre-push vulture dead-code scanner#1253

Open
seroperson wants to merge 1 commit into
entrius:testfrom
seroperson:vulture-integration
Open

chore: integrate pre-push vulture dead-code scanner#1253
seroperson wants to merge 1 commit into
entrius:testfrom
seroperson:vulture-integration

Conversation

@seroperson
Copy link
Copy Markdown
Contributor

Closes #1252

Summary

  • Added vulture==2.16 to dev deps and configured it in pyproject.toml. paths covers production tree only (gittensor, neurons, scripts); tests/ is omitted so test-only-API symbols (prod functions whose sole references live under tests/) surface as findings.
  • Excluded files whose schema mirrors an external wire format and shouldn't be pruned by static analysis: gittensor/validator/issue_competitions/contract_client.py (on-chain shape) and gittensor/utils/mirror/models.py (das-github-mirror response shape).
  • Framework false positives suppressed via [tool.vulture] ignore_decorators (@click.command/@click.group/@*.command/@*.group) and ignore_names
  • Hook: added vulture under stages: [pre-push] in .pre-commit-config.yaml. CI already runs SKIP=pytest pre-commit run --all-files --hook-stage pre-push, so the existing lint job picks it up. Renamed the step from "Run pyright" to "Run pre-push checks (pyright, vulture)" for accuracy.

Deletions surfaced by the scanner

  • gittensor/classes.py - FileChange.from_github_response, PullRequest.set_file_changes, PullRequest.current_labels, PullRequest.label_timeline_order, unused DefaultDict import.
  • gittensor/utils/utils.py - parse_repo_name, unused Dict import.
  • gittensor/utils/github_api_tools.py - get_github_id, a 3-line wrapper around get_github_identity(token).github_id. Only the retry test called it; that test now exercises get_github_identity directly and the retry coverage is preserved.
  • gittensor/validator/utils/datetime_utils.py - parse_github_timestamp_to_cst, CHICAGO_TZ, unused pytz import. All call sites disappeared with refactor: strip legacy scoring pipeline; mirror-only master repos #1202's strip of the legacy GraphQL constructors.
  • gittensor/validator/pat_storage.py - remove_pat. CRUD primitive with no prod caller; orphaned scaffolding for a deregister-cleanup path that was never wired up. TestRemovePat (3 tests) went with it.
  • gittensor/validator/storage/repository.py - refresh_stale_pr_states method, and the REFRESH_STALE_PR_STATES SQL constant in queries.py it consumed. The lone test reference was a defensive mock_repo.refresh_stale_pr_states.return_value = 0 setup, not a real test.
  • gittensor/constants.py - MAX_FILES_PER_GRAPHQL_BATCH.
  • neurons/base/validator.py - self.lock = asyncio.Lock(). Bittensor-template carry-over; never had an async with guard in this repo's history.
  • tests/validator/conftest.py - gutted to PRBuilder.create() only (the lone fixture/import test_pioneer_dividend.py actually consumes). pr_factory/issue_factory fixtures, IssueBuilder and its completed/transferred/not_planned/no_reason methods, MinerScenario, and all six miner-scenario fixtures - orphaned by refactor: strip legacy scoring pipeline; mirror-only master repos #1202.
  • tests/cli/test_cli_helpers.py - removed dead _Sentinel guard + exec_was_called plumbing in test_register_aborts_on_github_503_before_contract_call. The sentinel was defined but never patched into the test, so its "must not reach exec" assertion was vacuously true.
  • Renamed unused unpack/lambda vars to _-prefixed in gittensor/cli/issue_commands/helpers.py (_sign, _digits, exponent) and two test lambdas.

Testing

  • Tests added/updated
  • Manually tested

Test plan

uv run vulture                                           # exit 0, no findings
uv run ruff check                                        # all checks passed
uv run ruff format --check                               # 128 files already formatted
uv run pyright                                           # 0 errors, 0 warnings
uv run pytest tests/ -q                                  # 722 passed
SKIP=pytest uv run pre-commit run --all-files --hook-stage pre-push  # all hooks pass

How it looks like

image

@xiao-xiao-mao xiao-xiao-mao Bot added the refactor Code restructuring without behavior change label May 13, 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.

chore: integrate pre-push vulture dead-code scanner

1 participant