Skip to content
Discussion options

You must be logged in to vote

Hi!

You have to declare the default value slightly differently with Annotated. This should work as expected:

import typer
from typing import List
from typing_extensions import Annotated

app = typer.Typer()


@app.command()
def test2(test_list: Annotated[List[int], typer.Option()] = [1, 2, 3, 4]) -> None:
    for i in test_list:
        print(i)


if __name__ == "__main__":
    typer.run(test2)

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
2 replies
@ShihaoXu
Comment options

@YuriiMotov
Comment options

Answer selected by YuriiMotov
Comment options

You must be logged in to vote
5 replies
@svlandeg
Comment options

@svlandeg
Comment options

@saandaar
Comment options

@svlandeg
Comment options

@thht
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
6 participants