Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zsh completion has bogus #compdef value #703

Open
WhyNotHugo opened this issue Jan 2, 2025 · 1 comment
Open

Zsh completion has bogus #compdef value #703

WhyNotHugo opened this issue Jan 2, 2025 · 1 comment

Comments

@WhyNotHugo
Copy link

Describe the bug

The auto-generated completion files for zsh have a bogus #compdef directive so zsh won't apply them for the keyring command.

To Reproduce

> python -m keyring  --print-completion zsh | head
#compdef __main__.py

# AUTOMATICALLY GENERATED by `shtab`


_shtab___main___py_commands() {
  local _commands=(
    
  )
  _describe '__main__.py commands' _commands

Expected behavior

Should read #compdef keyring.

Environment

  • OS: Alpine Linux

Additional context

I'm adding completion scripts to the downstream Alpine package. This generation of completion needs to happen before the actual packaging phase, I'm using a temporary virtualenv to install keyring:

python3 -m venv --clear --without-pip --system-site-packages .tempenv
.tempenv/bin/python3 -m installer .dist/keyring-$pkgver-py3-none-any.whl
.tempenv/bin/python3 -m keyring --print-completion zsh > keyring.bash
.tempenv/bin/python3 -m keyring --print-completion zsh > keyring.zsh
@WhyNotHugo
Copy link
Author

Looks like $0 is unconditionally used for the completion script, but this doesn't make sense when the value is __main__.py.

Using .tempenv/bin/keyring --print-completion zsh > keyring.zsh produces the correct results.

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

No branches or pull requests

1 participant