edornd / argdantic

Typed command line interfaces with argparse and pydantic
MIT License
38 stars 4 forks source link

Better type handling in Arguments #27

Closed edornd closed 1 year ago

edornd commented 1 year ago

Describe the bug The current type handling using a dictionary is a bit bug-prone. E.g., date datetime or time are not included in NAMES as they do not represent primitive types strictly speaking, howver this introduces a two-fold problem.

  1. including them in the type dictionary, makes argparse attempt the parsing itself instead of forwarding it to pydantic
  2. not including them does not allow the definition of more descriptive metavars (i.e., DATE instead of TEXT)

To Reproduce Simply defining a List[date] is enough.

Expected behavior Date/time objects (and other complex standard and non-standard data types) should be "acknowledged", meaning that, if possible, argparse should be aware of them (at the very least using an ad-hoc metavar) but pydantic should take care of the heavy lifting.

edornd commented 1 year ago

Related to PR #26

edornd commented 1 year ago

Satisfied so far, might reopen later, idk.