Skip to content

[FEATURE] Literal type support #76

@alippai

Description

@alippai

Support for the literal type (python 3.8 or via typing_extensions) would be nice. Eg.

def get_list(output: Literal["raw", "json", "yaml"] = "raw"):
  if output == "json":
    typer.echo(json.dumps([1, 2, 3]))

The only workarounds (using string or multiple bool flags + validating input) are ugly now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature, enhancement or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions