Skip to content

[BUG] Completions that include colons get separated in zsh #162

Description

@jaywonchung

Describe the bug

I have completions (via the autocompletion keyword argument in Arguments and Options) that include a colon (:) in the string. In zsh, these completions get split into completion candidates and help texts at the colon.

To Reproduce

  • Create a file main.py with:
import typer

images = ["alpine:latest", "nvidia/cuda:10.0-devel-ubuntu18.04"]

def _complete(value: str) -> str:
    for image in images:
        if image.startswith(value):
            yield value

app = typer.Typer()

@app.command("image")
def hello(name: str = typer.Option(..., autocompletion=_complete)):
    typer.echo(name)

if __name__ == "__main__":
    app()
  • Trigger autocompletion with [TAB] on ZSH
$ <app_entrypoint> image --name [TAB]
  • It outputs:
$ <app_entrypoint> image --name [TAB]
alpine       -- latest
nvidia/cuda  -- 10.0-devel-ubuntu18.04

When I cycle through the completion candidates, only alpine and nvidia/cuda gets filled in.

  • But I expected it to output:
$ <app_entrypoint> image --name [TAB]
alpine:latest
nvidia/cuda:10.0-devel-ubuntu18.04

Environment

  • OS: Ubuntu 18.04
  • Typer Version: 0.3.2
  • Python version: 3.7.9
  • Zsh version: 5.4.2 (x86_64-ubuntu-linux-gnu)

Additional context

I tried the exact same thing in Bash, and it worked as expected (the output in "But I expected it to output").

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions