Skip to content

Title: fix(cli): stop bittensor argparse from hijacking click --help - #853

Merged
anderdc merged 4 commits into
entrius:testfrom
plind-junior:fix/cli-help-bittensor-argparse-hijack
May 4, 2026
Merged

Title: fix(cli): stop bittensor argparse from hijacking click --help#853
anderdc merged 4 commits into
entrius:testfrom
plind-junior:fix/cli-help-bittensor-argparse-hijack

Conversation

@plind-junior

@plind-junior plind-junior commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Summary

gitt --help and every gitt <subcommand> --help invocation printed bittensor's bt.config argparse output instead of click's command tree. Only bare gitt (no args) showed the correct help. New users hitting --help first saw a screen with --logging.debug flags and none of the actual commandsminer, issues, vote, admin, harvest, config, completion were all invisible.

Type of Change

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

Reproduction (before this PR)

$ gitt --help
usage: gitt [-h] [--logging.debug] [--logging.trace] [--logging.info] ...
options:
  -h, --help            show this help message and exit
  --logging.debug       Turn on bittensor debugging information.
  ...
# (no commands listed)

$ gitt miner --help        # same broken output
$ gitt i --help            # same broken output
$ gitt -h                  # same broken output

$ gitt                     # ✅ correct — full click help

Before
image

After
image

`gitt --help` and `gitt <subcmd> --help` printed bittensor's bt.config
argparse output instead of click's command tree, because importing
bittensor at module load parses sys.argv and exits on -h/--help before
click runs. Bare `gitt` worked.

Extend the existing stub gate (PR entrius#704, used for shell completion) to
also fire when -h/--help is in argv. Help-only invocations don't need
the real bittensor — click resolves help text from decorators without
running command bodies.
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.
@anderdc

anderdc commented May 4, 2026

Copy link
Copy Markdown
Collaborator

hi I can't see the images you have

@anderdc anderdc added the enhancement New feature or request label May 4, 2026
@plind-junior

Copy link
Copy Markdown
Contributor Author

@anderdc I've fixed the PR description and you can check images here

@anderdc
anderdc merged commit 316f815 into entrius:test May 4, 2026
3 checks passed
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.

2 participants