Skip to content

fix: stub heavy imports during shell completion - #704

Merged
anderdc merged 2 commits into
entrius:testfrom
seroperson:completion-speedup
Apr 23, 2026
Merged

fix: stub heavy imports during shell completion#704
anderdc merged 2 commits into
entrius:testfrom
seroperson:completion-speedup

Conversation

@seroperson

@seroperson seroperson commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Closes #703

Summary

Completions were introduced in #431 and seemd work quite fast, but currently they're noticeable slow. You can check it either right during completion attempt or by running:

$ time _GITT_COMPLETE=zsh_complete COMP_WORDS="gitt " COMP_CWORD=1 gitt >/dev/null
0.711 total

The reason is heavy bittensor import which was introduced to the main.py by #637:

# added in #637:
from gittensor.utils.github_api_tools import make_graphql_headers, make_headers

# gittensor/utils/github_api_tools.py:
import bittensor as bt

Such heavy-imports issue is already solved in allways (entrius/allways#45), so looks like it's time to replicate the same fix here.

After

$ time _GITT_COMPLETE=zsh_complete COMP_WORDS="gitt " COMP_CWORD=1 gitt >/dev/null
0.081 total

@xiao-xiao-mao xiao-xiao-mao Bot added the enhancement New feature or request label Apr 22, 2026
@anderdc
anderdc merged commit f34cbfe into entrius:test Apr 23, 2026
3 checks passed
plind-junior added a commit to plind-junior/gittensor that referenced this pull request Apr 29, 2026
Ruff flagged the previous form (two assignments + if-block before later
imports) with E402 'module level import not at top of file'. Collapsing
the gate back to a single conditional preserves the conditional-import
idiom that ruff E402 looks past, matching the pre-existing pattern from
PR entrius#704.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] gitt shell completion is slow due to heavy imports

2 participants