Skip to content

Fix Fish completion for Fire(fn) - #701

Open
reginaldalfret wants to merge 1 commit into
google:masterfrom
reginaldalfret:fix-418-fish-completion
Open

reginaldalfret wants to merge 1 commit into
google:masterfrom
reginaldalfret:fix-418-fish-completion

Conversation

@reginaldalfret

@reginaldalfret reginaldalfret commented Sep 24, 2026 •

Copy link
Copy Markdown

Summary

This PR fixes Fish shell completion when fire.Fire is called on a top-level function (fire.Fire(fn)), analogously to PR #336 which previously resolved this behavior for Bash completion.

Background & Root Cause

In fire/completion.py, _FishScript iterates through commands_set constructed from subcommands_map.keys() and options_map.keys(). When fire.Fire targets a top-level function, subcommands_map and options_map are empty dictionaries, so commands_set remained empty. As a result, no complete -c <name> ... directives were emitted for the function's arguments.

Solution

Add name to commands_set in _FishScript (identical to the fix applied to _BashScript in #336):

commands_set = set()
commands_set.add(name)
commands_set = commands_set.union(set(subcommands_map.keys()))
commands_set = commands_set.union(set(options_map.keys()))

Testing

  • Added an assertion in TabCompletionTest.testFnFishScript to verify that complete -c identity -n '__fish_using_command identity; is emitted in the generated fish script.
  • Verified unit tests pass with pytest.
  • Verified style and lint checks with pylint (10.00/10) and ty.

Fixes #418

Add command name to commands_set in _FishScript so that top-level function CLI completion registers completion directives for the command's flags. Analogous to google#336 which fixed the same issue for Bash completion.

Fixes google#418

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check if we need an analogous fix to #336 for the fish completion script generator

1 participant