Skip to content

typer.Argument with autocompletion #334

Closed
@mdantonio

Description

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Typer documentation, with the integrated search.
  • I already searched in Google "How to X in Typer" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to Typer but to Click.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

Not working:
    myparam: str = typer.Argument(
        "",
        shell_complete=my_autocomplete,
    )

Working:
    myparam: str = typer.Option(
        "",
        shell_complete=my_autocomplete,
    ),

Description

I'm trying to enable shell complete on an Argument but it does not work. On the opposite with Options everything is working as expected

I think that the same problem was already in the previous versions of typer (so that it is NOT introduced by typer 0.4.0 & click 8... but i'm not totally sure about that)

Based on tests on click, shell_complete on arguments should work: https://github.com/pallets/click/blob/48cb86d85fc1abfcf1478ee660e42aaa5382fd64/examples/completion/completion.py#L25

in typer I can't find tests with arguments, I only found this with option https://github.com/tiangolo/typer/blob/a1520dcda685220a9a796288f5eaaebd00d68845/tests/assets/compat_click7_8.py#L20

Operating System

Linux

Operating System Details

Ubuntu 20.04

Typer Version

0.4.0

Python Version

Python 3.9.5

Additional Context

click 8.0.1

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions