Skip to content

Use with_annotated decorator with custom types for allow easy type conversion #1688

@neoniobium

Description

@neoniobium

Feature Request

When using the argparse approach (with_argparse decorator), the type argument of add_argument can be used for non-basic type conversion (see for example). The same is not possible when using the with_annotated decorator.

Possible design for a solution

Either allow custom types (as Typer does — see custom types) and make a best-effort type conversion for arbitrary annotations, or add an additional parameter to Option and Argument (for example conversion) that enables a two-step type conversion approach.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions