Skip to content

determine type using just type, when default is string #73

Description

@Esgariot

According to argparse docs on that matter,

If the type keyword is used with the default keyword, the type converter is only applied if the default is a string.

I'm trying to parse datetime, expect the input (and generated help) to be in %Y-%mformat.

class Args(tap.TypedArgs):
    gen_conf: bool = tap.arg("--gen-conf",help="generate example config",default=False)
    since: datetime = tap.arg(default=datetime.strftime("%Y-%m"), type=datetime.strptime) # str | datetime

couldn't type have proprity over default in this case? or, if type is a -> T and default is a, couldn't default be "type-applied" against type?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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