Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
Esgariot opened this issue Sep 29, 2024 · 0 comments
Open

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

Esgariot opened this issue Sep 29, 2024 · 0 comments

Comments

@Esgariot
Copy link

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?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant